Here is source code of the C program to illustrate the concept of unions. The C program is successfully compiled and run on a Linux system. The program output is also shown below.
* C program to illustrate the concept of unions
union number x;
printf("Enter the value of n1: ");
printf("Value of n1 = %d", x.n1);
printf("\nEnter the value of n2: ");
printf("Value of n2 = %f\n", x.n2);
$ cc pgm93.c $ a.out Enter the value of n1: 10 Value of n1 = 10 Enter the value of n2: 50 Value of n2 = 50.000000
Sanfoundry Global Education & Learning Series – 1000 C Programs.
Here’s the list of Best Reference Books in C Programming, Data-Structures and Algorithms