Questions tagged [cash.c]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0
votes
1answer
26 views

Coin count off by 1 in cash

When I input an amount into the program cash, it gives me one more coin than I should have and I'm not sure how to fix it #include <stdio.h> #include <cs50.h> #include <math.h> //...
0
votes
1answer
21 views

CASH issue - help needed

I've been struggling with this for a month now so any help will be appreciated. The program just returns the value of input, so although there are no errors in compiling, it doesnt actually produce ...
1
vote
2answers
11 views

cash (less) - ouput is not converting from dollars to cents or rounding

hi i'm trying to convert the users input from dollars to cents. every time it just prints exactly what i typed in, so if i enter 0.20, the output is 0.200000. my math.h seems to be having no effect ...
0
votes
1answer
97 views

CS50 pset 1 cash problem: keep getting 1 as answer

I'm trying to do the CS50 cash problem and the answer keeps getting number 1 no matter which change I input. It won't accept negative numbers as asked by the problem, but I don't know why it doesn't ...
0
votes
1answer
75 views

cash CS50 2020 pset1 modulo

I seem to be having trouble using modulo as conditions inside of while loops. int main() { float n; do { n = get_float("How much change is owed? "); } while(n < 0); int cents = round(...
0
votes
1answer
67 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
88 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
51 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
24 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
129 views

PSet1 cash, modulo problem

Why does this give 19 instead of 20 when change = 4.2? Thanks.
0
votes
1answer
526 views

pset1 cash.c check50 outputs 1 error?

I am receiving this output from check50 on pset1 cash.c :) cash exists :) cash compiles :) input of 0.41 yields output of 4 :) input of 0.01 yields output of 1 :) input of 0.15 yields output of 2 :) ...
0
votes
1answer
195 views

pset1 cash.c Do While loop executing even when condition = false?

I am inputting 0.26 into cash.c, and after the first do while loop in my program, f = 0.00999999046 My second do while loop condition is f >= 0.10, yet it is executed even though f is less than that. ...
0
votes
1answer
252 views

how to carry over value of int through while loops (cash/less)

I am attempting the cash exercise (less comfortable) on pset1. I've created four different while loops to help count how many coins change there should be. I tried the program out with just the first ...
0
votes
1answer
140 views

cash.c I dunno which part is incorrect

I havent finished the whole, just the dollar part. But the formulation cannot be run correctly Can anyone tell me which part is incorrect?
1
vote
1answer
9k views

pset1 cash.c guidance

I am stuck on pset1 cash problem. When I run my script I get a blank and it never completes the calculation. The best I've been able to display is 0 even though its the wrong answer. I figure I ...