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
1 vote
Accepted

Why should I use round in greedy?

You understand the round function correctly, it does round a float to the nearest whole number. …
Cliff B's user avatar
  • 69.3k
2 votes
Accepted

Still Need Help. Pset1 Geedy with round()

Try running the following code: #include <stdio.h> int main(void) { int c = 2; c = c - 0.25; printf("2 - 0.25 = %i", c ); } THe result is 2 - 0.25 = 1 Next, the round() function rounds … Now look at this line of code: change = round(GetFloat()) * 100; This will round to the nearest dollar before multiplying by 100. …
Cliff B's user avatar
  • 69.3k
1 vote

Pset1 Greedy Help Please

The point of the exercise has been missed - floats are frequently not precisely stored. If you want to see the problem, try printing cents to a precision of 20 digits after the decimal. Also, for ea …
Cliff B's user avatar
  • 69.3k
2 votes
Accepted

Pset1 Cash - Trying to round float value DURING computation and not after

First, remember that round functions round the input to the nearest whole number, not to a particular digit. … With that in mind, the idea is to multiply dollars by 100 to get cents, round it to the nearest cent and store in in an int, not a float. …
Cliff B's user avatar
  • 69.3k
2 votes
Accepted

PSet1 Cash returning implicitly declaring library function 'roundf' with type 'float (float)'

Have you read the man page for the function? Maybe there's something your should include in your code that isn't there? ;-) If this answers your question, please click on the check mark to accept. …
Cliff B's user avatar
  • 69.3k
-1 votes
Accepted

pset1 greedy, help pleeeease

First, any extra printf statement will cause check50 to fail no matter what, so they need to be commented out to run check50. The code has serious logic issues. It contains a string of if/else if co …
Cliff B's user avatar
  • 69.3k