I want it to ask user for a float input to assign to money such as a dollar. The smallest unit would be a cent or 0.01 so I want it to reprompt the user for input every time he enters a negative value or zero. The while condition seems fine. What is wrong with it?
#include <stdio.h>
#include <cs50.h>
#include <math.h>
int main(void)
{
float amount = 0;
do
{
printf("How much change to be returned?\n");
amount = GetFloat();
}
while(amount < 0.01);
}
Sample run:
jharvard@appliance (~/Dropbox/pset1): ./greedy
How much change to be returned?
0.01
How much change to be returned?
As you can see when I enter 1 cent it repeats the loop. If I enter 0.02 it works but I want to know why it's doing this.