Answer:
Here the code is given as follows,
#include <stdio.h>
#include <stdlib.h>
union floatingPoint {
float floatNum;
double doubleNum;
long double longDoubleNum;
};
int main() {
union floatingPoint f;
printf("Enter data for type float: ");
scanf("%f", &f.floatNum);
printf("\nfloat %f ", f.floatNum);
printf("\ndouble %f ", f.doubleNum);
printf("\nlong double %Lf ", f.longDoubleNum);
printf("\n\nBreakdown in Hex");
printf("\nfloat in hex %x ", f.floatNum);
printf("\ndouble in hex %x ", f.doubleNum);
printf("\nlong double in hex %Lx ", f.longDoubleNum);
printf("\n\nEnter data for type double: ");
scanf("%lf", &f.doubleNum);
printf("float %f ", f.floatNum);
printf("\ndouble %f ", f.doubleNum);
printf("\nlong double %Lf ", f.longDoubleNum);
printf("\n\nBreakdown in Hex");
printf("\nfloat in hex %x ", f.floatNum);
printf("\ndouble in hex %x ", f.doubleNum);
printf("\nlong double in hex %Lx ", f.longDoubleNum);
printf("\n\nEnter data for type long double: ");
scanf("%Lf", &f.longDoubleNum);
printf("float %f ", f.floatNum);
printf("\ndouble %f ", f.doubleNum);
printf("\nlong double %Lf ", f.longDoubleNum);
printf("\n\nBreakdown in Hex");
printf("\nfloat in hex %x ", f.floatNum);
printf("\ndouble in hex %x ", f.doubleNum);
printf("\nlong double in hex %Lx ", f.longDoubleNum);
return 0;
}