The payroll program is supposed to accept a structure of the id number, name, hours, and rate of each employee. Then, the program is supposed to calculte the gross pay or each employee and display it along with the id number and name. My program is running without any compiler errors but the displayed output is incorrect and it only display one set of numbers not the 6 for each employee.
#include <stdio.h>
#include <stdlib.h>
#define NUMEMP 6
struct NetPay
{
int id;
char name[10];
double rate, hours;
};
int main()
{
int i;
double payment[6];
struct NetPay employee[NUMEMP] = {{3462, "Jones", 4.62, 40.0},
{6793, "Robbins", 5.83, 38.5},
{6985, "Smith", 5.22, 45.5},
{7834, "Swain", 6.89, 40.0},
{8867, "Timmins", 6.43, 35.5},
{9002, "Williams", 4.75, 42.0}};
for (i =0; i < NUMEMP; i++)
{
payment[i]= employee[i].rate*employee[i].hours;
}
printf("The gross pay of %d %s is %lf\n", employee[i].id, employee[i].name, payment[i]);
system ("pause");
return 0;
}