Sunday, 11 December 2011

Write a program to use of structure’s members form of array in c

#include
#include

struct employee
{
int empno;
char name[20];
int age;
}
e[5];
void main()
{
int i;
clrscr();
printf("Enter details for five employees\n");
for(i=0;i<5;i++)
{
printf("\nEnter the employee number name and age for employee %d\n",i+1);
fflush(stdin);
scanf("%d%s%d",&e[i].empno,e[i].name,&e[i].age);
}
for(i=0;i<5;i++)
{
printf("\n\nThe details of employee %d\n",i+1);
printf("%d\t%s\t%d",e[i].empno,e[i].name,e[i].age);
}
getch();
}

OUTPUT
Enter details for five employees
Enter the employee number name and age for employee 1
1MAHESH 23
Enter the employee number name and age for employee 2
2 raju 24
Enter the employee number name and age for employee 3
3 harish 22
Enter the employee number name and age for employee 4
4 SIKENDER 22
Enter the employee number name and age for employee 5
5 SANDEEP 23
The details of employee 1
1 MAHESH 23
The details of employee 1
2 VIJAYKUMAR 24
The details of employee 1
3 harish 22
The details of employee 1
4 SIKENDER 22
The details of employee 1
5 SANDEEP 23

No comments:

Post a Comment