-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstructs.c
More file actions
45 lines (38 loc) · 1.01 KB
/
structs.c
File metadata and controls
45 lines (38 loc) · 1.01 KB
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include <stdio.h>
typedef struct
{
int eNo;
char eName[30];
int DOJ;
int salary;
}
employee;
int main()
{
int nEmployees;
printf("Enter number of employees: ");
scanf("%d", &nEmployees);
employee employees[nEmployees];
for(int i = 0; i < nEmployees; i++)
{
printf("------Employee no. %d------\n", i + 1);
printf("Enter eNo: ");
scanf("%d", &employees[i].eNo);
printf("Enter eName: ");
scanf("\n%[^\n]s", &employees[i].eName);
printf("Enter salary: ");
scanf("%d", &employees[i].salary);
printf("Enter DOJ (DDMMYYYY): ");
scanf("%d", &employees[i].DOJ);
printf("\n");
}
for(int i = 0; i < nEmployees; i++)
{
printf("------Employee no. %d------\n", i + 1);
printf("eNo: %d\n", employees[i].eNo);
printf("eName: %s\n", employees[i].eName);
printf("DOJ: %d\n", employees[i].DOJ);
printf("Salary: %d\n", employees[i].salary);
printf("\n");
}
}