what is the defrenece between structure and union

Answers were Sorted based on User's Feedback



what is the defrenece between structure and union..

Answer / kapildalke

Thanks for these answer renuka..............
it means that
struct student
{
int i;
char a,b;
}
it occupy 4 bytes of memory..........
and in case of union
union student
{
int i;
char a,b;
}
it occupies only 2 byte memory.............

Am i write or wrong

Is This Answer Correct ?    21 Yes 0 No

what is the defrenece between structure and union..

Answer / renuka

structure is declared with the keyword struct and structure
variables occupy individual memory location.But Unoin is
declared with the keyword union and its variables are
allocated to a memory at which the highest byte of the
variable is declared.

Is This Answer Correct ?    16 Yes 0 No

what is the defrenece between structure and union..

Answer / abhradeep chatterjee

all of you are correct. ya, structure is declared with the
keyword struct and structure
variables occupy individual memory location.But Unoin is
declared with the keyword union and its variables are
allocated to a memory at which the highest byte of the
variable which is declared.

Is This Answer Correct ?    3 Yes 0 No

what is the defrenece between structure and union..

Answer / shruti

Kapildalke -> u are rite..

the differance between a structure and union is that,

in structure memory is allocated to each and every element
of the structure.

in union memory allocated is only of the element which
requires maximum memory.

Is This Answer Correct ?    2 Yes 0 No

what is the defrenece between structure and union..

Answer / nayanprakash

union is better then structure.union is declared with
keyword union.it can store more data which can store at
hights byte of veeriable is declared.structure is declred
a keyword struct.it will store for indivisul memory space.

Is This Answer Correct ?    1 Yes 5 No

Post New Answer

More C Interview Questions

What is return type in c?

0 Answers  


Write a C program in Fibonacci series.

0 Answers   iNautix,


Is main is user defined function?

0 Answers  


Reverse the part of the number which is present from position i to j. Print the new number. eg: num=789876 i=2 j=5 778986

1 Answers  


Why void main is used in c?

0 Answers  






write a c program for print your name .but,your name may be small letter mean print a capital letter or your name may be capital letter mean print a small letter .example \\enter ur name : sankar The name is: SANKAR (or) enter your name:SAnkar The name is:saNKAR

3 Answers   IBM,


how the size of an integer is decided? - is it based on processor or compiler or OS?

19 Answers   HCL, JPR, Microsoft, nvidia,


What does typedef struct mean?

0 Answers  


What is an auto variable in c?

0 Answers  


What is a pointer?

1 Answers   ADP, IFFCO,


wat is output of the following int main() { const int j=2; int i; switch(i) { case 1:break; case j:break; default:break; } }

2 Answers  


Discuss similarities and differences of Multiprogramming OS and multiprocessing OS?

4 Answers   TCS,


Categories