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

To find whether a number is even or odd without using any conditional operator??

12 Answers   College School Exams Tests, IBM,


identify the in correct expression a.a=b=3=4; b.a=b=c=d=0; float a=int b=3.5; d.int a; float b; a=b=3.5;

8 Answers   TCS,


What is the description for syntax errors?

0 Answers  


I need a sort of an approximate strcmp routine?

0 Answers  


Explain 'bus error'?

0 Answers  






You are to write your own versions of strcpy() and strlen (). Call them mystrcpy() and mystrlen(). Write them first as code within main(), not as functions, then, convert them to functions. You will pass two arrays to the function in the case of mystrcpy(), the source and target array.

0 Answers  


find the minimum of three values inputted by the user

3 Answers  


What are the two types of structure?

0 Answers  


Write a program that takes a 5 digit number and calculates 2 power that number and prints it.

5 Answers   TCS, Vimukti Technologies,


List the different types of c tokens?

0 Answers  


What is a pragma?

0 Answers  


How many data structures are there in c?

0 Answers  


Categories