# Error: greedy cash input of 0.41 yields output of 4

I'm getting an error and I can't figure out the solution to this problem. I get an error at check cs50: "input of 0.41 yields output of 4; expected "4\n", not "You typed: 0.41..."

Here is my code:

``````#include <stdio.h>
#include <cs50.h>
#include <math.h>

int main (void)

{

float cents;
int coins, change;

do
{
cents = get_float ("Change: ");
} while (cents <= 0);

change = (int) roundf(cents * 100);

printf("You typed: %f\n", cents);
printf("You typed: %d\n", change);

for (coins = 0; change > 0; coins++)
{

if (change >= 25)
{
change -= 25;
}
else if (change < 25 && change >= 10)
{
change -= 10;
}
else if (change < 10 && change >= 5)
{
change -= 5;
}
else
{
change -= 1;
}
}

printf("Coins: %d\n", coins);

}
``````

I searched for a solution to this problem but I could not find anything that worked. Thank you for your time!

`check50` does an automated test.

This means that some program will look at your output, and tries to see whether it is the same as expected.

Actually, the specifications say:

we ask that your programâ€™s last line of output be only the minimum number of coins possible: an integer followed by `\n`.

Therefore, the program looks at all your output, and checks (for this input) whether it is exactly the same as `4\n`. And in your case, it isn't ...

Finally, to quote Cliff B:

If this answers your question, please click on the check mark to accept. Let's keep up on forum maintenance. ;-)

• Thank you for answering! I had a minor error which apparently solved the problem with check50! Not sure why it had that error, but I guess it's solved now. Side note: I forgot to add change >= 10 in dimes and that was making all the trouble -- so it seems.
– Ffs
Oct 23, 2018 at 11:39