It is correct for every input except "4.2". The output should be 18, but my code is giving it to be 22 and I have absolutely no idea why this is happening.
#include<cs50.h>
#include<stdio.h>
int main (void)
{
float n = -1;
printf("O hai! ");
while (n < 0)
{
printf("How much change is owed?\n");
n = GetFloat();
};
n = n * 100;
int count = 0;
int A[] = {25, 10, 5, 1};
int i;
for (i = 0; i < 4; i++)
{
while (n >= A[i])
{
n = n - A[i];
count++;
}
}
printf("%d\n", count);
}
My CHECK50 screenshot is here:
The only conclusion I could deduce is that the universe is trying to tell me something (the number 42). Thank you for reading this question.