I have written the following code as a part of pset1 for greedy. I always seem to get a number less than the actual number of coins.Please help me out.
#include <stdio.h>
#include <cs50.h>
int main(void)
{
int n=0, x;
float c;
do
{
printf("O hai! How much change is owed?\n");
c=GetFloat();
if((c/0.25)>=1)
{
x=c/0.25;
n=n+x;
c=c-(x*0.25);
}
if((c/0.10)>=1)
{
x=c/0.10;
n=n+x;
c=c-(x*0.10);
}
if((c/0.05)>=1)
{
x=c/0.05;
n=n+x;
c=c-(x*0.05);
}
n=n+(c*100);
}while(c<=0);
printf("%i\n", n);
}