#include <stdio.h>
struct emptyStr{
    
};
union emptyUni{
    
};
struct str{
 int a;
 int b;
 char str[20];
};
union uni{
    int a ;
    int b;
    char str[20];
};
int main() {
    printf("Struct union\n");
    printf("Size of empty struct is %d\n",sizeof(struct emptyStr));
    printf("Size of empty union is %d\n",sizeof(union emptyUni));
    
    printf("Size of struct is %d\n",sizeof(struct str));
    printf("Size of union is %d\n",sizeof(union uni));
    
    struct str s;
    s.a = 10;s.b=20;
    printf("Values of struct str a %d b %d\n",s.a,s.b);
    
    union uni u;
    u.a = 10;u.b=20;
    printf("Values of union uni a %d b %d\n",u.a,u.b);

    return 0;
}

Embed on website

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