Programming In C Practical 20
Question 1
Accept and Display 10 employees ’s information using structure.
Employee.cpp
C
#include<stdio.h>
#include<conio.h>
#include<string.h>
struct emp
{
int empid;
char name[50],designation[50];
};
void main()
{
clrscr();
struct emp e[5];
int i;
printf("\nEnter details of 5 employees\n");
for(i=0;i<5;i++)
{
printf("\nEnter name of employee:");
scanf("%s",e[i].name);
printf("Enter designation: ");
scanf("%s",e[i].designation);
printf("Enter employee id: ");
scanf("%d",&e[i].empid);
}
printf("\nEmployees information\n");
for(i=0;i<5;i++)
{
printf("\nEmployee id: %d",e[i].empid);
printf("\nName of employee: %s",e[i].name);
printf("\nEmployee designation: %s",e[i].designation);
}
getch();
}
Output
