difference between structure and union.

Answers were Sorted based on User's Feedback



difference between structure and union...

Answer / truong nguyen

Regarding the struct, each item in the struct is allocated
in a separated memory. And the size of a struct object is
total size of all its items.
But with the union, all its items are in the same memory.
And the size of an union object is size of its item which
has largest size.

Is This Answer Correct ?    24 Yes 0 No

difference between structure and union...

Answer / siva sankari

struct employee
{
int a[20];// for tis size 20 was allocated in memory
char text;// for tis only 1byte of memory space is allocated
}
so totally 21 in size was allocated in memory space

union employee
{
int a[20];// for tis size 20 was allocated in memory
char text;// for tis only 1byte of memory space is allocated
}
but in union it takes only the maximum memory space so for each 20space totally 40 size was allocated in memory space

Is This Answer Correct ?    7 Yes 12 No

Post New Answer

More OOPS Interview Questions

how to swap to variables without using thrid variable in java?

5 Answers  


What are oops methods?

0 Answers  


if u write a class do u write Assignment operator and copy constructor

1 Answers   Siemens,


why to use operator overloading

3 Answers  


How can i write a code in c# to take a number from the user and then find all the prime numbers till the number entered by the user.

4 Answers   NIIT, TCS,






what is polymorphism?

4 Answers  


What is pointer in oop?

0 Answers  


What is encapsulation with example?

0 Answers  


What do we mean by a hidden argument in a function?

1 Answers   TCL,


What is Iteration Hierarchy? What is what is Object behavioral concept?

1 Answers  


What is multiple inheritance? Give Example

6 Answers   Mind Tree,


what is opps?why it is use in programming language?

2 Answers   Wipro,


Categories