I have a problem with check50 and . Specifically the greedy program. In every instance my code would seem to get the right answer, however when checked with the check50 widget I get back the message ...

:( input of 4.2 yields output of 18
   \ expected output, but not "18"

I don't understand what is wrong here, my print statement is ...

printf("%d", totalCoins); // prints an int

And to add insult to injury, my mark in gradebook reflects the check50 problem. What have I done incorrectly? Hints please!

  • can you share your code you have written ? Aug 8 '15 at 21:22

You have to also print a newline after the number of coins.

Change this:

printf("%d", totalCoins);

to this:

printf("%d\n", totalCoins);

check50 expects very exact output. If you you have an extra space, prompt or carriage return (\n) or are missing one where there should be one, check50 will reject it. By chance, did you forget to output a \n when you printed your result?

You must log in to answer this question.

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