scanf for char input getting skipped

F

FerrisUML

Hello eveyone! Im working on the following program for an intro to C
class and I seem to be having a problem with the last scanf statement,
scanf("%c", &quitVal). Seems that its getting skipped and the program
simply exits. Is there something that im not seeing? Thanks if
advance.

int main()
{

int clock_number = 0;
float hours_worked = 0;
float hourly_rate = 0;
float total = 0;
char quitVal;

goto start;

start:

printf("Please enter the employee's clock number:\n");
scanf("%i", &clock_number);
printf("Please enter the employee's hourly rate:\n");
scanf("%f", &hourly_rate);
printf("Please enter the hours worked:\n");
scanf("%f", &hours_worked);
total = hourly_rate * hours_worked;
printf("Employee Clock Number\tHourly Rate\tHours Worked\tGross\n");
printf("%i\t\t\t%0.2f\t\t%0.2f\t\t%0.2f\n", clock_number,
hours_worked, hourly_rate, total);
printf("Do you want to quit:");
scanf("%c", &quitVal);
goto done;

done:

return 0;
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top