Please check the code below. It runs fine but with a few "errors". when I input 0.41 as per the problem example, it gives me 16 coin count instead of 4. What is missing? Please help me understand. the only thing I really know and understand so far is Line 1 (not shown) until 'int cents'. Thank you so much.
int i = 0; //initialize coin count from 0
int cents = round(change*100);
if (cents >= 25) //condition for coin count if change is greater than or equal to 25
{
cents = cents - 25;
i++;
}
else if (cents >= 10 && cents < 25) //coin count if change is greater than 10 and less than 25
{
cents = cents - 10;
i++;
}
else if (cents >= 5 && cents < 10)
{
cents = cents - 5;
i++;
}
else if (cents >= 1 && cents < 5)
{
cents = cents - 1;
i++;
}
printf("%i\n", cents);
}
}