You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
programming-examples/c/Basic/C Program to Illustrate the...

20 lines
401 B
C

/*
* C program to illustrate the concept of unions
*/
#include <stdio.h>
void main()
{
union number
{
int n1;
float n2;
};
union number x;
printf("Enter the value of n1: ");
scanf("%d", &x.n1);
printf("Value of n1 = %d", x.n1);
printf("\nEnter the value of n2: ");
scanf("%f", &x.n2);
printf("Value of n2 = %f\n", x.n2);
}