UNION IN C PROGRAMMING.

 #include<stdio.h>

#include<string.h>

union student
{
    int id;
    int marks;
    char fav_char;
    char name[34];
};
int main()
{
    union student s1;
    s1.id = 1;
    s1.marks = 45;
    s1.fav_char = 'u';
    strcpy(s1.name, "Aatifa");

    printf("The id is %d\n", s1.id );
    printf("The is marks %d\n", s1.marks);
    printf("The fav_char is %c\n", s1.fav_char);
    printf("The name is %s\n", s1.name);
    return 0;
}

OUTPUT:
The id is 1769234753 The is marks 1769234753 The fav_char is A The name is Aatifa

Comments

Popular posts from this blog

C Program using continue statement

C program of WHILE Loop

NULL Pointer in C.

C Program using DO WHILE loop

C Program using SWITCH statement

New Animated Login or signup page made by HTML, CSS and JavaScript.

C Program to print multiplication table of any number.

C Language Travel Agency Manager Exercise.

STRUCTURE IN C PROGRAMMING.