#include <stdio.h>
#include <string.h>

union data {
    int i;
    float f;
    char str[20];//largest is 20
};

int main() {
    union data d;
    d.i = 10;
    printf("d.i = %d\n", d.i);
    d.f = 3.14;
    printf("d.f = %.2f\n", d.f);
    strcpy(d.str, "hello");
    printf("d.str = %s\n", d.str);
    printf("d.i = %d\n", d.i);
    printf("%ld", sizeof(union data));
    return 0;
}

Embed on website

To embed this program on your website, copy the following code and paste it into your website's HTML: