Implement a union to store either an integer or a float and display the value based on the type chosen.
HardProblem Statement
Implement a union to store either an integer or a float and display the value based on the type chosen.
Sample Input
choice = 'i', value = 10
Sample Output
Integer Value: 10
Limits
Time: 2s · Memory: 256 MB
Code Editor
00:00
#include <stdio.h>
union Data {
int intValue;
float floatValue;
};
int main() {
union Data data;
char choice;
// Add logic to read choice and assign value
// Logic to display based on choice
return 0;
}
Input
choice = 'i', value = 10
Expected Output
Integer Value: 10