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

Write a code on reverse string and its complexity.

767


What could possibly be the problem if a valid function name such as tolower() is being reported by the C compiler as undefined?

1002


Differentiate fundamental data types and derived data types in C.

808


What happens if a header file is included twice?

776


What is the package for freshers(Non IIT) in amazon(hyderabad). And what is the same for those who are a contract employee.

3957


Where are some collections of useful code fragments and examples?

936


Sir,please help me out with the code of this question. Write an interactive C program that will encode or decode multiple lines of text. Store the encoded text within a data file, so that it can be retrieved and decoded at any time. The program should include the following features: (a) Enter text from the keyboard, encode the text and store the encoded text in a data file. (b) Retrieve the encoded text and display it in its encoded form. (c) Retrieve the encoded text, decode it and then display the decoded text. (d) End the computation. Test the program using several lines of text of your choice.

2002


Which is better oop or procedural?

807


By using C language input a date into it and if it is right?

792


Write programs for String Reversal & Palindrome check

782


Why is C language being considered a middle level language?

841


how should functions be apportioned among source files?

854


What are the primitive data types in c?

760


Differentiate between #include<...> and #include '...'

805


What is a pointer in c plus plus?

899