Questions tagged [pset1]

The problem set for Week 1 introduces the C programming language.

172 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
2
votes
1answer
170 views

How do I get past Chrome to submit assignments

I've got the three programs (hello, mario, and greedy) ready to submit but I can't get past Chrome, I have trouble remembering passwords, and they want to know the date I first signed up for Chrome. ...
1
vote
1answer
58 views

PSET1 Mario pyramid - Can someone explain me the logic of this line of code?

I was able to make the Mario's pyramid from Problem Set 1, (I know it should be right alligned, not left). This is the code, and it is working fine when I execute the program, but I don't seem to ...
1
vote
2answers
827 views

check50 says it's not authorized (it is)

Working on pset1 I have previously authorized my github for cs50.me. When I try to run check50 cs50/2017/x/hello, I get the error message "Looks like check50 isn't enabled for your account yet. Log ...
1
vote
0answers
636 views

Every 2nd digit on Pset1 Credit problem: Tldr bolded

Im struggling with manipulating the string of numbers in the credit problem. I've figured out how to divide the initial input number by 10 (*100 each iteration) then mod % by 10 in order to access the ...
1
vote
2answers
1k views

pset1 mario pyramid

Below is my code for mario.c which compiles and prints the required pyramid but for some reasons didnt pass check50. // a program that recreates this half-pyramid using hashes (#) for blocks #...
1
vote
2answers
106 views

Weird problem - gedit isn't saving changes to my mario code

I've restarted it several times, saved the code under another name and done everything I can think of but it isn't using the changes I've made. For example, I used dots to make the pyramid so I could ...
1
vote
1answer
101 views

Is it compulsory to use the appliance Chrome while uploading pset files?

In pset specifications, it is instructed to submit pset through Chrome inside appliance, not any other. Is it compulsory? I mean, can't anyone submit through any other computer? Or any other browser?
1
vote
2answers
872 views

pset1 mario: please help with my code

The below is what I have come up so far and the result is very underwhelming. It just doesn't work out as I expected. The first part works well but I am struggling with the second one. Any help would ...
1
vote
1answer
158 views

Program correctly responds to all the questions in gradebook but still not getting marks

My program for Greedy is correctly responding to all the questions in the gradebook but I'm still not getting marks. When I run check50 I get the following error: What should I do?
1
vote
3answers
1k views

Can't run the staff implementation

i can't run the staff implementation for any problem set, i always get the same error, it's always something like : bash: ~cs50/pset4/breakout: No such file or directory
0
votes
1answer
55 views

CS50W - Wiki with Django - I want to edit a wiki entry, but I don't know how to send the default value to the template if I use Django forms

I've tried to do this: class editPage(forms.Form): title = forms.CharField() textContent = forms.CharField(widget=forms.Textarea(attrs={'class' : 'textContent'})) def edit(request,name): ...
0
votes
1answer
11 views

When I multiply my array by 2 it doesn't give expected value

Also, please when I try to add "firstnumsum", it doesn't give expected value and I don't know what to do. #include <cs50.h> #include <stdio.h> #include <string.h> #include &...
0
votes
1answer
35 views

i don't know what's wrong with my code. Trying to convert from string to long

INPUT int main(void) { long long cardnumber, calc; string credit[0]; string nonnumeric; //long long calc = card number; int countcardcharacters = 0; long long c; //user input do { credit[0]= ...
0
votes
1answer
19 views

Pset1 Creating and Changing Directory Does Nothing

For the first problem set, I attempted to create and change the directory with the following commands: $ mkdir ~/pset1 $ cd ~/pset1 $ mkdir ~/pset1/hello $ cd ~/pset1/hello Despite doing these ...
0
votes
1answer
23 views

My code does what I want it to do, but I get errors with check50 (PSET1, MARIO, LESS)

When I run my code in the terminal it gives me the correct response. However, check50 indicates there is an issue with my spaces. I have spend 2 days looking at it but I dont know whats wrong. INPUT /...
0
votes
2answers
62 views

mario less comfortable help

I wrote this code for the mario problem but idk if it's right. i'm having trouble running it. It keeps saying error: linker command failed with exit code. #include <cs50.h> #include <stdio.h&...
0
votes
0answers
18 views

I got a “linker command failed with exit code 1” error after compiling my source code

clang -ggdb3 -O0 -std=c11 -Wall -Werror -Wextra -Wno-sign-compare -Wno-unused-parameter -Wno-unused-variable -Wshadow mario.c -lcrypt -lcs50 -lm -o mario /usr/bin/../lib/gcc/x86_64-linux-gnu/7.4.0/...
0
votes
0answers
68 views

I can't get the Luhn algorithm to run properly in my code

#include <stdio.h> #include <cs50.h> #include <math.h> int main(void) { long long cardnumber = 0; //Prompt the user for the credit card number using get_long do { ...
0
votes
2answers
29 views

pset 1 Question about difference between Mario and Cash (get_float get_n)

As I was trying to structure the user input section of both problems, I ran into some errors that I don't understand. For Mario, I separated the user input of the problem and int main(void) by placing ...
0
votes
1answer
63 views

Need help (or idea) making the code looks cleaner. (PSET1/CREDIT)

My code passed pset1/credit but I still think the there must be a way to make my code looks cleaner and more impact. If you have any idea please criticize the code. Thank you in advance. #include <...
0
votes
2answers
37 views

Pset1 How do I get my code to compile as it should?

I'm trying to get my code to compile properly and it just won't. I know the code works when using a printf and scanf but now that I've changed it to get_int and printf it is not working properly. I ...
0
votes
1answer
33 views

How to get my code to re-prompt when given a non numeric input?

So my code in C for the mario steps is correct except that it shows an output when foo is input rather than re-prompting for a valid integer. I did check50 and this was the only error. Where can I ...
0
votes
1answer
90 views

pset1 less comfortable mario

Somebody please help me I have watched the walkthrough thrice, many different videos and searched for answers on reddit and stackexchange yet i've been stuck at this for hours now and cant get through....
0
votes
1answer
50 views

HELP ME!! CS50 pset1 credit.c says INVALID but when I debug it says AMEX?

#include <stdio.h> #include <cs50.h> int main(void) { long long cc; //get user input for cc do { cc = get_long_long("Number: "); } while (cc <= 0); /...
0
votes
2answers
64 views

Pset1 Cash (in C) array increment error

Context; I'm trying to solve Cash by; Taking positive integer user input, saves as float "ch" for change. (this as an implementation detail) Create an array "coin_val" with coin value by descending ...
0
votes
1answer
51 views

pset1 Cash question

For some reason sometimes it gets the answers right and others it gets the answer wrong, I'm stuck so I don't know what to do next. #include <stdio.h> #include <cs50.h> #include <math....
0
votes
0answers
40 views

pset1 Cash, keeps answering 1

#include <cs50.h> #include <stdio.h> #include <math.h> int main(void) { float change; int coins = 0; do { change = get_float("Change owed: "); } ...
0
votes
1answer
66 views

pset1 cash: greedy algorithm coin change round off

The output is not being rounded off: It doesn't count the cents value if you input a dollar in decimal. if it's $45.67, it only counts change for $45. Also, output comes back 0 if the input is ...
0
votes
1answer
26 views

Check50 giving different results from the code I compiled in pset1

For Problem Set 1, I have the code as written below #include <cs50.h> #include <stdio.h> int card_length(long cNo); void luhn_algo(long lacno, int lacnolen); void finalPrint(int cardDet);...
0
votes
1answer
70 views

Problem Set 1 (Credit) - More Comfortable - 'Else' Block Not Running

I attempted Problem Set 1's 'More Comfortable' Credit assignment today, which is essentially to implement Luhn's mod 10 algorithm for checking that a given debit/credit card number is valid. I've ...
0
votes
1answer
36 views

PSET1 One input doesn't give the appropriate output

My current code checks out all the input values except for the integer value of 23. I'm not sure why, and the value is pretty close, 94, instead of 92. But what makes me truly confused is that other ...
0
votes
1answer
46 views

How do you check if a number is integer as part of if statement?

As part of the Mario assignment following lecture 1, I need to determine is the number input is an integer. What function can I use to do that? I have tried scanf("%d", &number), where number is a ...
0
votes
1answer
173 views

Stuck at pset 1 mario problem

I'm Stuck at the PSET 1 problem of CS50. for height 3, my output is coming as ..# ..## ..### Can any peers or experts, look into my code and help me out. [EDIT: code removed for Honor Code ...
0
votes
1answer
221 views

python pset1 cash problem

Trying to solve pset1 cash less comfortale with python. Whats my mistake as I cant figure it out. Lets say I add 5.16 as cash owed that is 20*0.25+1*0.1 +1*0.05 +1*0.01 , 23 coins total used. ...
0
votes
1answer
79 views

Pset1 cash.c Can't seem to wrap my head around it

So I'm just trying to slowly navigate my way through this problem by seeing if I can get the total amount to subtract 25 from the float. I keep getting an error message that says cash3.c:18:27: ...
0
votes
1answer
466 views

I keep getting error: use of undeclared identifier 'n' when trying to compile mario.c. I am new to coding, my code is shown below

#include <cs50.h> #include <stdio.h> int get_positive_int(string prompt); int main(void) { { int i=get_positive_int("Height:"); } for (int i = 1; i < n; i++) ...
0
votes
0answers
92 views

Pset1 mario only executing do-while loop

So i've spent way too much time on this. Didnt expect it to be so difficult. I think i got the coding right but for some reason the program is only executing till the do-while loop and then it exits ...
0
votes
1answer
59 views

Need help with my code! It will not compile and everything seems like it is correct. Please help and give me some pointers. Thanks in advance :)

#include <cs50.h> #include <stdio.h> #include <math.h> int main(void) { float f = get_float("How much change is owed: "); } float f = f x 100; int c = 0; while (f >= 25) ...
0
votes
1answer
43 views

The program not displaying the correct output for CREDIT Pset1

i have written the program for the credit but is not giving the expected output please let me Know if my code requires any change or if the logic is correct or wrong let me know. here is what i get ...
0
votes
1answer
234 views

pset1 - Mario less comfortable - Styling problem

Could any one please tell me what's the "styling problem" in this code? I keep getting score of 4 out of 5 and I don't understand what I miss ? #include <cs50.h> #include <stdio.h> int ...
0
votes
1answer
52 views

pset1 mario uncomf - Hash's start in wrong place

I've ran into what appears to be a problem. I initially thought I finished this pset but when I was checking my work I noticed the #'s always started from the 8th character along the line? Even if I ...
0
votes
1answer
112 views

Pset 1 Less comfortable - Number of Hashes

Sorry for the beginners's question. When I try to compile to following code for the Mario - Less Comfortable problem, I am printing the same number of hashes for each row and am unsure why. Code is ...
0
votes
1answer
201 views

PSET 1 Introduction to Python and Javascript linking database issue

I am having issues linking my flask program to Postgre SQL import os from flask import Flask, session from flask_session import Session from sqlalchemy import create_engine from sqlalchemy.orm ...
0
votes
1answer
72 views

pset1 credit working only in certain cases

So, this is probably not a good solution of the problem, but I hoped it would at least work, after struggling with it for quite some time. It made me happy to see it worked for the first number I ...
0
votes
1answer
58 views

set1/cash (or greedy)/ Floating point imprecision and rounding requirement help

I think I have figured out a way to convert the users input from dollars to cents. I used the eprintf function and it works. However, when re-watching Zamyla's walk through she mentions towards the ...
0
votes
1answer
42 views

Problems w/compiling pset1

Could anyone help me figure out why I can not compile, but get the following error: ~/workspace/pset1/mario/less/ $ make mario clang -fsanitize=signed-integer-overflow -fsanitize=undefined -ggdb3 -O0 ...
0
votes
1answer
67 views

Pset1 valid visa number as invalid

I built the first part to check whether a number is a valid AMEX number and used the same logic to check for Visa number but the codes don't seem to work as I tried with several valid visa numbers and ...
0
votes
3answers
102 views

Incorrect input of value yields incorect output in Cash task at PSet 1

My code #include <stdio.h> #include <cs50.h> #include <math.h> int main(void) { float sum; int sumInt; // Check user input and convert it to cents do { //eprintf("about to ...
0
votes
1answer
231 views

pset1 credit assignment

I assume anyone looking at this question knows the assignment but to recap I need to write a program that will identify different CC#s—AMEX, MC, VISA, or Invalid. Since all these CCs range from 13-16 ...
0
votes
1answer
32 views

An error with my code?

So recently I made a code for the CASH project in CS50, but for some reason its giving me wrong values for the total amount of coins when I think the code is correct. I posted my code down below, ...