ALLInterview.com :: Home Page            
 Advertise your Business Here     
Browse  |   Placement Papers  |   Company  |   Code Snippets  |   Certifications  |   Visa Questions
Post Question  |   Post Answer  |   My Panel  |   Search  |   Articles  |   Topics  |   ERRORS new
   Refer this Site  Refer This Site to Your Friends  Site Map  Bookmark this Site  Set it as your HomePage  Contact Us     Login  |  Sign Up                      
Google
   
 
Categories >> Software >> Programming Languages >> C
 
 


 

 
 C interview questions  C Interview Questions (2253)
 C++ interview questions  C++ Interview Questions (1111)
 VC++ interview questions  VC++ Interview Questions (342)
 Delphi interview questions  Delphi Interview Questions (510)
 Programming Languages AllOther interview questions  Programming Languages AllOther Interview Questions (646)
Question
What is the difference b/w Structure & Union?
 Question Submitted By :: C
I also faced this Question!!     Answer Posted By  
 
Answer
# 1
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
Nakul Sharma
 
Answer
# 2
in structure struct key word is used but in union union key
word is used.
 
Is This Answer Correct ?    6 Yes 9 No
Karthikkumareg
 
 
 
Answer
# 3
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
Raj Kumar
 

 
 
 
Other C Interview Questions
 
  Question Asked @ Answers
 
What's wrong with "char *p = malloc(10);" ?   4
from which concept of 'c', the static member function of 'c++' has came? Bosch 1
find largest of 3 no   8
Write a program to find given number is even or odd without using any control statement.   2
Write a C/C++ program that connects to a MySQL server and checks intrusion attempts every 5 minutes. If an intrusion attempt is detected beep the internal speaker to alert the administrator. A high number of aborted connects to MySQL at a point in time may be used as a basis of an intrusion. Vodafone 2
second highest number in a given set of numbers TCS 3
WHOT IS CHAR? TCS 4
WHAT IS HEADER? TCS 8
how do u find out the number of 1's in the binary representation of a decimal number without converting it into binary(i mean without dividing by 2 and finding out the remainder)? three lines of c code s there it seems...can anyone help   5
When you call malloc() to allocate memory for a local pointer, do you have to explicitly free() it? Aloha-Technology 2
what is volatile in c language? TCS 9
what is the difference between entry control and exit control statement?   7
 
For more C Interview Questions Click Here 
 
 
 
 
 


   
Copyright Policy  |  Terms of Service  |  Articles  |  Site Map  |  RSS Site Map  |  Contact Us
   
Copyright 2013  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  KalAajKal.com