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

Why c is a mother language?

0 Answers  


compute the nth mumber in the fibonacci sequence?

10 Answers   Canon, HPL, Satyam, TCS,


Write a program to show the change in position of a cursor using c

0 Answers  


What is the method to save data in stack data structure type?

0 Answers  


related proverb of "dont count your chicken before it hatches"

1 Answers  






consider the following C code main() { int i=3,x; while(i>0) { x=func(i); i--; } int func(int n) { static sum=0; sum=sum+n; return(sum); } the final value of x is

4 Answers   TCS,


whitch value return void main?

11 Answers  


How to find a missed value, if you want to store 100 values in a 99 sized array?

0 Answers   Honeywell, Zomato,


What is the difference between text files and binary files?

0 Answers  


Explain how can I prevent another program from modifying part of a file that I am modifying?

0 Answers  


How many types of linked lists what are they? How many types of data structures?

18 Answers   BSNL, Pivotal Software,


What is the best style for code layout in c?

0 Answers  


Categories