I ran this C program in Visual Studio 2010 but it just performed the 1st for
loop and then stopped working.
Please help me find a solution. I have also tried to place the second for
loop code into the 1st for
loop. It then shows the output but I want the output to be separately written for all employees.
#include<stdio.h>
struct Employee
{
int hours;
char Name[25];
char date[50];
long wages;
};
void main()
{
int i;
struct Employee Emp[2]; //Statement 1
for(i=0;i<2;i++)
{
printf("\nEnter details of %d Employee",i+1);
printf("\n\tEnter Employee Name : ");
scanf("%s",&Emp[i].Name);
printf("\n\tEnter Date in (dd/mm/yyyy) : ");
scanf("%s",&Emp[i].date);
x:
printf("\n\tEnter Employee Hours of Working(You are allowed maximum upto 4) : ");
scanf("%d",&Emp[i].hours);
if(Emp[i].hours <= 4)
{
Emp[i].wages=Emp[i].hours*100;
}
else
{
printf("\nPlease Enter proper hours of working");
goto x;
}
}
for(i=0;i<2;i++)
{
printf("\nDetails of Employees");
printf("\n%s\t%s\t%ld",Emp[i].Name,Emp[i].date,Emp[i].wages);
}
getchar();
}