Use structure within union - C Language Programming

Use structure within union - C Language Programming

Program in C Language to use structure within union

Click here to open this program in Turbo C++

 Statement - Use structure within union
 Programmer - Vineet Choudhary
 Written For -


void main() {
    struct student {
        char name[30];
        char sex;
        int rollno;
        float percentage;
    union details {
        struct student st;
    union details set;
    printf("Enter details:");
    printf("\nEnter name : ");
    printf("\nEnter roll no : ");
    scanf("%d", &;
    printf("\nEnter sex : ");
    scanf("%c", &;
    printf("\nEnter percentage :");
    scanf("%f", &;
    printf("\nThe student details are : \n");
    printf("\name : %s",;
    printf("\nRollno : %d",;
    printf("\nSex : %c",;
    printf("\nPercentage : %f",;
You've successfully subscribed to Developer Insider
Great! Next, complete checkout for full access to Developer Insider
Welcome back! You've successfully signed in
Success! Your account is fully activated, you now have access to all content.