#include <stdio.h>
#include <conio.h>
void main()
{
union number
{
int n1;
float n2;
};
union number x;
clrscr() ;
printf(“Enter the value of n1: “);
scanf(“%d”, &x.n1);
printf(“Value of n1 =%d”, x.n1);
printf(“\nEnter the value of n2: “);
scanf(“%d”, &x.n2);
printf(“Value of n2 = %d\n”,x.n2);
} /* End of main() */
/*————————————
Output
Enter the value of n1: 2
Value of n1 =2
Enter the value of n2: 3
Value of n2 = 0
————————————*/
Not Satisfied ? Just search & get the result
Related posts:
- C program to input real numbers and find the mean, variance and standard deviation
- C program to check whether a given integer number is positive or negative
- C program to accept a set of numbers and compute mean, variance and standard deviation
- C program to accept an array of 10 elements and swap 3rd element with 4th element using pointers. And display the results
- C program to read two integers M and N and to swap their values. Use a user-defined function for swapping. Output the values of M and N before and after swapping with suitable messages
