#include <cs50.h>
#include <stdio.h>
int main(void)
{
float change, quarter, dime, nickel, penny;
int coins;
do {
change = get_float("Change: ");
} while (change < 0);
quarter = 0.25;
dime = 0.10;
nickel = 0.05;
penny = 0.01;
coins = 0;
while (change != 0)
{
if((change-quarter) >= 0)
{
change = change - quarter;
coins += 1;
}
else if ((change - dime) >= 0)
{
change = change - dime;
coins += 1;
}
else if ((change - nickel) >= 0)
{
change = change - nickel;
coins += 1;
}
else if ((change - penny) >= 0)
{
change = change - penny;
coins += 1;
}
}
printf("%d", coins);
printf("\n");
}
It works with numbers 1, 1.5, 2, 2.5 and some others which are nicely rounded, but as soon as i type another number like 0.41 it stops right there.
What is the issue?