After I submitted my cash pset1, it returned three test cases(input of 1.6,23 and 4.2) giving the wrong output(7,92,18), also detailed in check50. But when I try the three test cases with my code, my code returned the correct answers to the prompt(3,0,2).
The check50 output is :( input of 1.6 yields output of 7 :( input of 23 yields output of 92 :( input of 4.2 yields output of 18
My code is as follows:
#include <stdio.h>
#include <cs50.h>
#include <math.h>
int main(void)
{
float x, v;
int c, a;
int i = 0;
do
{
//ask user for input
x = get_float("owed change is: ");
v = x - (int)x;
c = round(v * 100);
}
while (x < 0);
while (c >= 25)
{
c -= 25;
i++;
}
while (c >= 10)
{
c -= 10;
i++;
}
while (c >= 5)
{
c -= 5;
i++;
}
i += c;
printf("%i\n", i);
}
'''