-
Notifications
You must be signed in to change notification settings - Fork 0
/
3.c
41 lines (26 loc) · 935 Bytes
/
3.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
32
33
34
35
36
37
38
39
40
41
#include <stdio.h>
union WorkerData {
char workerName[50];
float salary;
};
struct Worker {
union WorkerData data;
};
int main() {
struct Worker workers[2];
printf("Enter the name of the first worker: \n ");
scanf("%s", workers[0].data.workerName);
printf("Enter the salary of the first worker: \n ");
scanf("%f", &workers[0].data.salary);
printf("Enter the name of the second worker: \n");
scanf("%s", workers[1].data.workerName);
printf("Enter the salary of the second worker: \n");
scanf("%f", &workers[1].data.salary);
printf("\nWorker 1\n");
printf("Name: %s\n", workers[0].data.workerName);
printf("Salary: %.2f\n\n", workers[0].data.salary);
printf("Worker 2\n");
printf("Name: %s\n", workers[1].data.workerName);
printf("Salary: %.2f\n", workers[1].data.salary);
return 0;
}