explain about storage of union elements.

Answer Posted / anandi

Union elements can share the common memory spaces.

For eg.

union stu
{
int rno;
int mark;
float total;
};

In this pg, the compiler allocates 4 bytes to store the
union members. Bcoz, in this pg, the float data type only
requires the large memory size, ie, 4 bytes. And the
remaining members can share this 4 bytes. So if u want to
store rno, it will allocate the first 2 bytes.
And also we can store only one value at a time to the
memory.

Is This Answer Correct ?    6 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are local static variables? How can you use them?

636


What should malloc() do?

637


What is use of #include in c?

589


What is the value of h?

585


Do you know the use of fflush() function?

592






What is malloc() function?

629


Explain modulus operator.

588


Write a function which takes as parameters one regular expression(only ? and * are the special characters) and a string and returns whether the string matched the regular expression.

642


How will you divide two numbers in a MACRO?

697


WRITE A PROGRAM TO MERGE TWO SORTED ARRAY USING MERGE SORT TECHNIQUE..

1585


What is structure padding and packing in c?

609


What is sizeof int in c?

592


Is there a way to switch on strings?

607


How do you convert strings to numbers in C?

701


What functions are used for dynamic memory allocation in c language?

592