Define Union. Explain Union in detail. (JAN 2009)
Union is a collection of variables similar to structure. The union requires bytes that are equal to number of bytes required for the largest number.
Example:
union student
{
char name[20];
int rollno,m1,m2,m3,tot;
float avg;
}s1;
Union of structure
Union can be nested with another union.
Example program:
· Program to use structure within union. Display the contents of structure elements
Union is a collection of variables similar to structure. The union requires bytes that are equal to number of bytes required for the largest number.
Example:
union student
{
char name[20];
int rollno,m1,m2,m3,tot;
float avg;
}s1;
Union of structure
Union can be nested with another union.
Example program:
· Program to use structure within union. Display the contents of structure elements
No comments:
Post a Comment