Ok so this is my improved code:
#include <stdio.h>
#include <cs50.h>
#include <math.h>
int main (void)
{
float c;
int a, n=0;
do
{
c = get_float("Change: ");
}
while (c < 0);
//Round for each type of coin
c *=100;
a =round(c);
//quarters
while (a >= 25)
{
n++;
a -= 25;
}
//dimes
while (a >= 10)
{
n++;
a -=25;
}
//nickels
while (a >=5)
{
n++;
a -= 25;
}
//pennies
while (a >=1)
{
n++;
a -= 25;
}
//print coins
printf("%i\n", n);
}
So it works for some values but doesn't work for others. Ex. if I input 0.41 it gives me 2 which is incorrect but if I input 65 it outputs 260 which is correct. Can someone help me on this issue? Thanks!