-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathQ27.c
More file actions
25 lines (23 loc) · 664 Bytes
/
Q27.c
File metadata and controls
25 lines (23 loc) · 664 Bytes
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
/* program: 27
Write a c program to demonstrate the use of union.
*/
#include <stdio.h>
union employee
{
long int eno;
char name[30];
int salary;
} em;
int main()
{
printf("\nEnter Employee name: ");
gets(em.name);
printf("Name: %s\n", em.name);
printf("\nEnter Employee ID no: ");
scanf("%ld", &em.eno);
printf("ID no: %ld\n", em.eno);
printf("\nEnter Employee salary: ");
scanf("%d", &em.salary);
printf("salary: %d", em.salary);
return 0;
}