# Greedy passes all but 1 check .41

I am a little stuck on the Greedy problem. My code passes all test but one, the .41 test. The output always comes to 3 when it should be 4. I am not sure why?

quarters += (cents / 25);
remaining = (cent % 25);

dimes += (remaining/10);
remaining = (cents % 10);

nickles += (remaining / 5);
remaining = (cents % 5);

pennies += (remaining / 1);

coin_count = quarters + dimes + nickels + pennies

Thanks,

R

A lot of typos here, check the comments:

quarters += (cents / 25);
remaining = (cent % 25); // This should be (cents % 25) not (cent % 25)

dimes += (remaining/10);
remaining = (cents % 10); // Should be remaining % 10

nickles += (remaining / 5);
remaining = (cents % 5); // Should be remaining % 5

pennies += (remaining / 1);

coin_count = quarters + dimes + nickels + pennies

Fixed:

quarters += (cents / 25);
remaining = (cents % 25); // This should be (cents % 25) not (cent % 25)

dimes += (remaining/10);
remaining = (remaining % 10); // Should be remaining % 10

nickles += (remaining / 5);
remaining = (remaining % 5); // Should be remaining % 5

pennies += (remaining / 1);

coin_count = quarters + dimes + nickels + pennies
• That fixed it completely, thank you.
– user5075
Mar 7, 2015 at 13:08