I having a problem with a program that I'm creating. I need the program to get the users hourly rate for a job, and if they enter a negative number, or 0 it gives them an error message. So far this what what I have:
/* Enter hourly rate */
printf("Enter hourly rate: ");
scanf("%f", &hourlyRate);
/* check hourlyRate */
while(hourlyRate > 0)
{
printf("*** ERROR: hourly rate must be positive\n");
printf("Enter hourly rate: ");
scanf("%f", &hourlyRate);
}//end while
I'm wanting the program to display this error message until a positive number higher than 0 is inputted. As is, the program runs an infinite loop.Could someone please advice me what I am doing wrong.
Thanks in Advance;
S0n1C!


Sign In
Create Account

Back to top









