I am trying to learn how to code and I have been stuck on my greedy algorithm for hours. My greedy algorithm is not outputting numbers correctly for example .41 will output 3 instead of 4.
#include <stdio.h>
#include <math.h>
int main(void)
{
float cents;
int coinsused=0;
do{
cents=get_float("Change Owed: " );
}
while (cents<0.00);
for(float quarter=0.25; cents>=quarter; cents-=quarter){
coinsused++;
}
for(float dime=0.10; cents>=dime; cents-=dime){
coinsused++;
}
for(float nickle=0.05; cents>=nickle; cents-=nickle){
coinsused++;
}
for (float penny=0.01; cents>=penny; cents-=penny){
coinsused++;
}
printf("%i\n",coinsused);
}