Help with last part of struct
Quote:
Hi I have almost all of my program complete I think, but what I can't figure out is how do I include the Total Gross of all the employees at the end of my program. I know I need a printf statement but I'm not sure what else I need and how to make it work. Please help
Code:
#include <stdio.h>
struct Info
{
int Id_Number;
char Last_Name[20];
float Pay_Rate;
float Hours_Worked;
float Gross_Pay;
float Total_Gross_Pay;
};
int main()
{
struct Info info[1];
int p;
for (p = 0; p < 6; p++)
{
printf("\n\nEnter the employee Id Number? ");
scanf("%d", &info[p].Id_Number);
printf("\nEnter the employee Last Name? ");
scanf("%s", &info[p].Last_Name);
printf("\nEnter the employee Pay Rate? ");
scanf("%f", &info[p].Pay_Rate);
printf("\nEnter the employee Hours Worked? ");
scanf("%f", &info[p].Hours_Worked);
info[p].Gross_Pay = ((info[p].Pay_Rate) * (info[p].Hours_Worked));
}
printf("\nLast Name Id Number Gross Pay");
printf("\n_________ _________ _________");
for (p = 0; p < 6; p++)
{
printf("\n%-20s %-20d %2.2f", info[p].Last_Name, info[p].Id_Number, info[p].Gross_Pay);
}
printf("\n___________________________________________________________");
printf("\n-----------------------------------------------------------");
getchar();
getchar();
return 0;
}