What is the difference b/w Structure & Union?
Answers were Sorted based on User's Feedback
Answer / nakul sharma
Memory allocated for any structure is equal to the sum of
memory required by each structure member.
Example: In a structure 'abc' below, memory allocated will
be 7 Bytes (2 Bytes for int a + 1 Byte for char b + 4 Bytes
for float c ina 32 bit processor)
struct abc
{
int a;
char b;
float c;
}
But in union memory allocated for it is equal to the memory
required by the biggest (in terms of memory it use) union
member.
Example: In a union 'abc' below, memory allocated will be 4
Bytes as float c is the biggest union member here and it
uses 4 Bytes of memory in 32 bit processor.
union abc
{
int a;
char b;
float c;
}
| Is This Answer Correct ? | 19 Yes | 1 No |
Answer / karthikkumareg
in structure struct key word is used but in union union key
word is used.
| Is This Answer Correct ? | 6 Yes | 9 No |
Answer / raj kumar
struct can hold multiple data types.
Like u can define a date structure....
but union can multiple data types which includes struct also
union x
{
int x;
struct
{
...
...
}
}
| Is This Answer Correct ? | 2 Yes | 7 No |
When we use void main and int main?
Where static variables are stored in memory in c?
Why does the call char scanf work?
Why is c fast?
What is the difference between int main and void main?
what is available in C language but not in C++?
10 Answers CTS, TCS,
When should a type cast be used?
Why void is used in c?
what is the disadvantage of using macros?
2. Counting in Lojban, an artificial language developed over the last fourty years, is easier than in most languages The numbers from zero to nine are: 0 no 1 pa 2 re 3 ci 4 vo 5 mk 6 xa 7 ze 8 bi 9 so Larger numbers are created by gluing the digit togather. For Examle 123 is pareci Write a program that reads in a lojban string(representing a no less than or equal to 1,000,000) and output it in numbers.
write a program of palindrome(madam=madam) using pointer?
any limit on the number of functions that might be present in a C program a) max 35 functions b) max 50 functions c) no limit d) none of the above