Questions tagged [pset1]

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

Filter by
Sorted by
Tagged with
1
vote
1answer
25 views

PSet1: Mario - Less Comfortable (Too many periods)

I recently just tipped my toes into the water of CS50 last week, I'm completely new to this so I need a bit of constructive critisism. I was completed stumped at first, but I got somewhat close - not ...
0
votes
1answer
30 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
61 views

Pset 1 mario (less comfortable)

I've been working on this problem for days and I can't figure out how to print the right side of the pyramid. I"m able to print the left side, preceded by a space (denoted by "y) and one hash. I've ...
0
votes
1answer
12 views

PSET1 clang hello.c

Can anyone tell me why I'm getting this error when trying to compile hello.c in the Terminal Window? $ clang hello.c hello.c:7:1: error: expected identifier or '(' { ^ 1 error generated. $ Thanks!
0
votes
1answer
15 views

The test shows this failure: expected exit code 0, not 4

#include <cs50.h> #include <stdio.h> #include <math.h> int main(void) { // prompts user for amount of change until user enters a valid number float dollars; do { ...
0
votes
1answer
26 views

Modulo math and while loops in cash.c

I'm not sure why my while loops do not give me the correct answer: while (cents % 25 > 0) { count++; cents -= 25; } while (cents % 10 > 0) { count++; ...
0
votes
2answers
72 views

mario (less) getting 53% score

I submit pset1 Mario (less), and my code works correctly but in cs50.me showing that I have only 53% scores even though that my code work correctly. #include <cs50.h> #include <stdio.h> ...
0
votes
0answers
20 views

CS50 Sandbox doesn't load in pset1

When I try to work on one of problems of pset 1, my Sandbox does not load correctly. While the initial loading screen is completed and I get the layout with the command line and code panes, nothing ...
0
votes
1answer
79 views

pset 1 Mario code starts with an empty row

I think I got most of it already but I have one issue that I don't see how to solve. If I make the height 8 (for example) it'll print 1 empty row first and then 7 rows with hashes, the last row will ...
0
votes
1answer
45 views

Hello.c pset1 problem, syntax error near unexpected token `(' and User input problem

Ive been doing pset 1 Hello and at the last part about User Input, Im at a loss for what to do. On the instructions, there are some hints where it says two commands. When I put down the two commands I ...
0
votes
1answer
48 views

Pset 1 .cash weird expected output

I finally managed to come up with something like this. I believe it works just fine but when the machine checks it, all the answers are wrong. E.g. when you are owed 0.41 you should get one from each ...
0
votes
1answer
43 views

How to return a value from a loop?

I have been trying to return value "a" to print it from while loop but can't find any ways so far. #include <cs50.h> #include <stdio.h> #include <math.h> int main(void) { float ...
0
votes
1answer
81 views

CS50; PSet1; Don't know how to connect for loop with user's input + expected identifier or '(' error

I don't know how to properly connect user's input part and for-loop(which is incorrect) in this program. I was seeking for how to do this but didn't find anything useful. Here are my code: #include &...
0
votes
1answer
41 views

Why removing a printf function messes up with my code? CS50 pset1 cash greedy challenge

I finished the challenge and my first C code worked apparently well, returning each time the correct minimum number of coins needed for change. Then when I tried to "clean it up" a bit and remove a ...
0
votes
1answer
79 views

Can’t see my error on Mario for loop, rows won’t execute!

I’ve gotten stuck on the Less Comfortable Mario set: the height input portion works, but the loop does not execute. I really wanted to figure this out on my own, but I’ve been stuck for days! Please ...
0
votes
1answer
41 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
59 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
93 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
1answer
127 views

Struggling with Mario (less comfortable) loop conditions

Been struggling with this a few times now and have inserted some additional printf commands to try and understand what's going on with the variables used to control my loops (please see instructions, ...
1
vote
1answer
141 views

Doing mario.c less comfortable one step at a time

Like many others here I am completely new to coding. No experience whatsoever. I have been busy with the less comfortable Mario.c for a while now, trying to understand what is going on every step of ...
0
votes
0answers
53 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
0answers
18 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 :)) [duplicate]

This code is for the cash problem for problem set 1. I am trying to find my errors but can't find them. Is my syntax, or spacing wrong? My ideas? Anything would be helpful. Thank you in advance.
0
votes
0answers
10 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 :) [duplicate]

This code is for the cash problem for problem set 1. I am trying to find my errors but can't find them. Is my syntax, or spacing wrong? My ideas? Anything would be helpful. Thank you in advance.
0
votes
1answer
39 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) ...
1
vote
2answers
74 views

I don't know why check50 HATES ME?! mario.more

Here's my code for mario.more. [removed solution code] When i execute this code, it performs exactly how it should look according to Walkthrough: But when I run check50, the terminal goes like ...
0
votes
3answers
199 views

I am ABSOLUTELY STUCK! (mario less)

Ok, I have tried and have gotten a 60%. I need at least a 70% to pass. Please. Help. Me. Please. Tell. Me. What. Do. I. Do. I am done cash and now I'm stuck on this! Here is my code: #include <...
0
votes
1answer
67 views

It doesn't work?!!! (Mario less)

Ok so this is my code: #include <cs50.h> #include <stdio.h> int main(void) { int n; do { n = get_int("Height: "); } while (n <= 0 || n > 23); for (int i = 0; i <= n; i++) ...
0
votes
1answer
40 views

pset1 credit formula to extract digits keeps returning 0 (potential data type issue?)

Below is the block of code that i have issue with. I'm using this method to extract the digits: num[i] = (num % pow(10, i))/pow(10, i-1). The pow1 and pow2 variables print out correctly, but "digit" ...
0
votes
1answer
68 views

Need guidance on Mario (Less Comfortable) Problem Set 1 (Pyramid upside down)

I recently got to trying to solve problem set 1, where I am required to print a pyramid with a user inputted value between 1 and 8 (inclusive). After a while, I got this code: #include <cs50.h> ...
0
votes
1answer
47 views

I need help with cash - again

Ok so this is my improved code: #include <stdio.h> #include <cs50.h> #include <math.h> int main (void) { float c; int a, n=0; do { c = get_float("Change: "); } while (...
0
votes
1answer
47 views

I need help. (pset 1 - cash) I don't get this!

So this is the code I have now: #include <stdio.h> #include <cs50.h> #include <math.h> int main (void) { float c; int i; do { c = get_float("Change: "); } while (c <...
0
votes
1answer
43 views

I don't understand where I went wrong?

So this is the code I have right now for cash in problem set 1. I don't know whats wrong. #include <stdio.h> #include <cs50.h> #include <math.h> int maid (void) { float c; ...
0
votes
1answer
18 views

Transform function into a loop or similar

So my problem is in problem set 1 of week 1 of the CS50 Harvard course. The task was writing a program that calculates the smallest amount of coins possible when getting change. I've already written ...
0
votes
1answer
196 views

How to print out hashes in mario(less comfortable)? (2019)

Ok so this is my code I have right now: #include <cs50.h> #include <stdio.h> int get_positive_int(string prompt); int main(void) { int i = get_positive_int("Height: "); for (i = 0; i < ...
0
votes
1answer
20 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
19 views

Small difference in pennies.c answers

Good day, I am very new to coding and trying my best, but my answers are correct for this problem, but not after the decimal. For example, the answer for 28 days in month and 1 pennies must be ...
1
vote
2answers
60 views

error at while loop cs50 Pset1 credit

I am getting an error at while loop it says error: '&&' within '||' [-Werror,-Wlogical-op-parentheses] while((credit % 10 >= 0) && (i < 15) || (i < 16)) here is my ...
0
votes
1answer
62 views

pset1 - problem with credit ..help plz

I spent so many hours and still can't figure the problem, any guidance would be appreciated.. I checked against all the paypal test numbers and got same response as the staff's execution, though I got ...
0
votes
1answer
103 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
43 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
18 views

Adding a code block to perform operations on float

I am currently on PSET 1 Cash and have my program asking for the amount of change required, not accepting negative values and now I want to add a code block to start performing the operations on my ...
0
votes
1answer
86 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
2answers
64 views

Problem Set 1, Cash: maths issues

I have been trying to fix this code for the last day, and still can't work out where I am going wrong. Can anyone point me in the right direction please? Thanks in advance! int main(void) { // ...
0
votes
1answer
250 views

Pset 1 - Mario pyramid trouble with spaces/dots

So I was able to set up the prompt and the left aligned pyramid correctly, but really started struggling when trying to right-align it with dots in front of the hashes. For whatever reason, its ...
0
votes
2answers
42 views

pset1 always adding extra one space on each Hash row

#include <cs50.h> #include <stdio.h> int main() { int height; do { height = get_int("Enter the height between 1 & 8\n"); }while(height<1 || height>8); for(int i=0; i<...
1
vote
1answer
65 views

pset 1 cash get_positive_float not functioning as intended

I wanted to get the positive float using the get_positive_float function, which I declared later. However, it either accepts -0.99999 or rejects 0.999999. The code looks as follows: #include <...
0
votes
1answer
71 views

pset1 - credit - if-else statement issue

I have written a (clumsy) solution to the credit pset1. However, the solution only works for "Mastercard" credit card numbers (i.e. 5555555555554444). For "Visa" and "Amex" my code does return the ...
0
votes
1answer
161 views

incompatible pointer to integer conversion initializing 'int'

#include <stdio.h> #include <cs50.h> int main(void) { printf("Give me a number between 1 and 10"); int n= get_int; if (n>=0 && n<=3) { printf("You ...
0
votes
1answer
49 views

pset1 - credit fails check50 compilation with “expected exit code 0, not 1” but compiles locally

My solution for "credit" compiles just fine with make, but when using check50, I get :( credit.c compiles. expected exit code 0, not 1 My code is as follows: #include <stdio.h> #include &...
0
votes
1answer
250 views

pset 1 Cash Question: runtime error: signed integer overflow problem

I am very new to coding and I can't seem to understand what is causing the runtime error: signed integer overflow. My code runs and allows me to enter a change amount when prompted, but fails after ...