Skip to main content
Search type Search syntax
Tags [tag]
Exact "words here"
Author user:1234
user:me (yours)
Score score:3 (3+)
score:0 (none)
Answers answers:3 (3+)
answers:0 (none)
isaccepted:yes
hasaccepted:no
inquestion:1234
Views views:250
Code code:"if (foo != bar)"
Sections title:apples
body:"apples oranges"
URL url:"*.example.com"
Saves in:saves
Status closed:yes
duplicate:no
migrated:no
wiki:no
Types is:question
is:answer
Exclude -[tag]
-apples
For more details on advanced search visit our help page
Results tagged with
Search options answers only not deleted user 4847
2 votes

"cash.c:7:1: error: expected identifier or '('" What do I do?

Get rid of the semicolon on line 6. A semicolon there marks the line as a function signature. You'll learn more about that later.
Cliff B's user avatar
  • 69.3k
1 vote
Accepted

pset1 cash.c check50 outputs 1 error?

You already understand all the parts of what's happening. Time to put them all together. The round function always rounds at the decimal. It's a simple fix. Move the decimal before you round. Don't …
Cliff B's user avatar
  • 69.3k
2 votes
Accepted

CS50 problem set 1 cash

Try printing out the value of cents after each calculation and think about the effect of integer division vs. regular division. Does the code track BOTH the number of coins for each denomination AND t …
Cliff B's user avatar
  • 69.3k
0 votes
Accepted

CASH issue - help needed

Sorry to hear you've been fighting this for so long. The do/while loop will never accept a value greater than zero because of the test. You want the loop to repeat only when the input value is negativ …
Cliff B's user avatar
  • 69.3k
-1 votes
Accepted

Coin count off by 1 in cash

This is an easy one. Coin count is off by one all the time, right? The variable coins is used to count the number of coins counted. What is it initialized to, 1 or 0? If this answers your question, …
Cliff B's user avatar
  • 69.3k
1 vote
Accepted

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

It's doing exactly what it was told. Remember the differences between a while loop and a do/while loop. A while loop can only execute if the condition is true because the test condition is checked B …
Cliff B's user avatar
  • 69.3k
1 vote
Accepted

Transform function into a loop or similar

Its good that you're thinking about how to make the code more efficient. Kudos to you! Yes, repeating code is a red flag that things can be simplified. But here, the code is very similar but not the …
Cliff B's user avatar
  • 69.3k
1 vote
Accepted

Code not working - cash

The problem is that the code uses do/while loops when it should have used while loops. A do/while loop will ALWAYS run at least once. That means that it will add 4 coins and subtract at least 25 cents …
Cliff B's user avatar
  • 69.3k
1 vote
Accepted

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

Why does the code increment the amount of change, i, each time it subtracts the value of a coin from it? You should be using a separate variable to track the number of coins.
Cliff B's user avatar
  • 69.3k
1 vote
Accepted

cash CS50 2020 pset1 modulo

Why are you using modulo for this? It produces an unreliable result in this usage. Further, the actual numbers don't make sense. The modulo function returns the remainder after an integer division. …
Cliff B's user avatar
  • 69.3k
1 vote
Accepted

CS50 pset 1 cash problem: keep getting 1 as answer

The problem that you're seeing is here: quantity = round (quantity * 100); So, what is the value of quantity before this line execute? What variable actually contains the value of the change to b …
Cliff B's user avatar
  • 69.3k