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 |
What is the use of function overloading in C?
Can true be a variable name in c?
#include<stdio.h> #include<conio.h> void main() { clrscr(); int a=0,b=0,c=0; printf("enter value of a,b"); scanf(" %d %d",a,b); c=a+b; printf("sum is %d",c); getch(); }
Explain what is wrong with this program statement?
What is the package for freshers(Non IIT) in amazon(hyderabad). And what is the same for those who are a contract employee.
Write a program to check whether a number is prime or not using c?
What is a struct c#?
Diff between for loop and while loop?
How is pointer initialized in c?
inline function is there in c language?
will u please send me the placement papers to my mail???????????????????
Unsigned char c; for ( c=0;c!=256;c++2) printf("%d",c); No. of times the loop is executed ?