0
:) greedy.c exists
:) greedy.c compiles
:( input of 0.41 yields output of 4
 \ expected output, but not "4"
:( input of 0.01 yields output of 1
\ expected output, but not "1"
:( input of 0.15 yields output of 2
\ expected output, but not "2"
:( input of 1.6 yields output of 7
\ expected output, but not "7"
:( input of 23 yields output of 92
\ expected output, but not "92"
:( input of 4.2 yields output of 18
\ expected output, but not "18"
:) rejects a negative input like -.1
:) rejects a non-numeric input of "foo"
:) rejects a non-numeric input of ""

Program Output:

yesaswi@ide50:~/workspace/pset1/greedy $ make greedy clang -ggdb3 -O0 -std=c11 -Wall -Werror -Wshadow greedy.c -lcs50 -lm -o greedy                      
yesaswi@ide50:~/workspace/pset1/greedy $ ./greedy O hai! How much change is owed? 0.41 4 
yesaswi@ide50:~/workspace/pset1/greedy $ ./greedy O hai! How much change is owed? 0.01 1 
yesaswi@ide50:~/workspace/pset1/greedy $ ./greedy O hai! How much change is owed? 0.15 2 
6
  • probably you are printing string instead of integer? Can you post your code? – Wafeeq Jun 21 '16 at 10:28
  • Do you have "\n" after when you print 4 ? (as per your example in above comment) – Wafeeq Jun 21 '16 at 10:44
  • Thanks for your response @Gullu Butt. I tried posting my code but eventually ended up out of characters. My programs outputvwill be as following yesaswi@ide50:~/workspace/pset1/greedy $ make greedy clang -ggdb3 -O0 -std=c11 -Wall -Werror -Wshadow greedy.c -lcs50 -lm -o greedy yesaswi@ide50:~/workspace/pset1/greedy $ ./greedy O hai! How much change is owed? 0.41 4 yesaswi@ide50:~/workspace/pset1/greedy $ ./greedy O hai! How much change is owed? 0.01 1 yesaswi@ide50:~/workspace/pset1/greedy $ ./greedy O hai! How much change is owed? 0.15 2 – Yesaswi Guntur Jun 21 '16 at 10:49
  • I have checked it now it came up well. My problem is solved. Thank you @Gullu Butt yesaswi@ide50:~/workspace/pset1/greedy $ check50 2015.fall.pset1.greedy greedy.c :) greedy.c exists :) greedy.c 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 :) input of 1.6 yields output of 7 :) input of 23 yields output of 92 :) input of 4.2 yields output of 18 :) rejects a negative input like -.1 :) rejects a non-numeric input of "foo" :) rejects a non-numeric input of "" – Yesaswi Guntur Jun 21 '16 at 10:53
  • Please accept the answer as solved below to Keep this Forum maintained. You can find the answer below. – Wafeeq Jun 21 '16 at 10:53
0

You should print an int followed by "\n" (new line) as a result of your program.

You should not accept any Input which is a minus value and not an alphanumeric. Write something which ignores any value with is negative and/or not a alphanumeric and ask the user to Input again.

You did not post any code so i will leave it for you how you do it.

e.g; -0.1, foo and " " should not be accepted as valid Inputs, discard them because they are negative and not numeric numbers.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .