-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstructure.c
33 lines (29 loc) · 850 Bytes
/
structure.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include<stdio.h> //Header file
struct employee // Initializing structure
{
char name[20];
int id,pno,salary;
}e[5]; // we can call structure employee by e[i]
void main() // Main fuction of void return type
{
int i;
for(i=0;i<=4;i++) // for-loop for taking input from user
{
printf("Enter %d employee's name: ",(i+1));
scanf("%s",e[i].name);
printf("\nEnter ID No.: ");
scanf("%d",&e[i].id);
printf("\nEnter Phone Number: ");
scanf("%d",&e[i].pno);
printf("\nEnter Salary: ");
scanf("%d",&e[i].salary);
}
printf("Employee's Details are:\n");
for(i=0;i<=4;i++) // for-loop for printing details of employee
{
printf("%d. Name: %s\n",(i+1),e[i].name);
printf(" ID No.: %d\n",e[i].id);
printf(" Phone Number :%d\n",e[i].pno);
printf(" Salary : %d\n",e[i].salary);
}
}