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 (2254)
 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 is the output of the below code? main( ) { printf ( "\nOnly stupids use C?" ) ; display( ) ; } display( ) { printf ( "\nFools too use C!" ) ; main( ) ; }   2
what is the difference between static variable and register variable?   3
what is the difference between %d and %*d in c languaga? TCS 6
What is the difference b/w Structure & Union?   3
52.write a “Hello World” program in “c” without using a semicolon? 53.Give a method to count the number of ones in a 32 bit number? 54.write a program that print itself even if the source file is deleted? 55.Given an unsigned integer, find if the number is power of 2?   7
could u able to tell about suresoft technical session   1
What is the relation between # and include<stdio.h> HCL 5
write a C code to reverse a string using a recursive function, without swapping or using an extra memory. Motorola 9
write a program to produce the following output; ABCDEFGFEDCBA ABCDEF FEDCBA ABCDE EDCBA ABCD DCBA ABC CBA AB BA A A   12
How to print "Hi World" without using semi colon? Infosys 6
Write a C program that defines a 2-dimentional integer array called A [50][50]. Then the elements of this array should randomly be initialized either to 1 or 0. The program should then print out all the elements in the diagonal (i.e. a[0][0], a[1][1],a[2][2], a[3][3], ……..a[49][49]). Finally, print out how many zeros and ones in the diagonal. Infosys 3
How to convert a binary number to Hexa decimal number?? (Note:Do not convert it into binary and to Hexadecimal) Subex 1
 
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