F
FerrisUML
Hello everyone! I new to C and am having the following problem. In
the below program, the last scanf is being ignored and the program
exits. Can anyone see anything that im doing wrong? Thanks in
advance.
#include <stdio.h>
/*
HOMEWORK: Assignment 1
Name: Dennis McQuilken
Class: C Programming
Date: 9.19.2008
Description: This is a C program that will calculate an employees
gross pay based on hours work and hourly rate.
*/
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;
}
the below program, the last scanf is being ignored and the program
exits. Can anyone see anything that im doing wrong? Thanks in
advance.
#include <stdio.h>
/*
HOMEWORK: Assignment 1
Name: Dennis McQuilken
Class: C Programming
Date: 9.19.2008
Description: This is a C program that will calculate an employees
gross pay based on hours work and hourly rate.
*/
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;
}