Union in C
×

Union in C

3081

The syntax of Union in C programming language is identical to structure except for the keyword.

Syntax of Union in C Programming Language:

Union Tag-name

<Datatype1> m1
<Datatype2> m2
.
.
.
}union-var;

Simple example explaining union in C programming language

Union Student

{
Int rollnumber;
Char name[15];
};
main()
Union student stud;
Printf("enter student roll number");
Scanf("%d",&stud.rollnumber);
Printf("enter student name");
Scanf(%s,&stud.name);
Printf("detail of student");
Printf("rollnumber:%d"stud.rollnumber);
Printf("student name:%s"stud.name);
getch();
}



Best WordPress Hosting


Share:


Discount Coupons

Get a .COM for just $6.98

Secure Domain for a Mini Price



Leave a Reply


Comments
    Waiting for your comments