ALLInterview.com :: Home Page KalAajKal.com
 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                      
tip   To Refer this Site to Your Friends   Click Here
Google
 
Categories  >>  Code Snippets  >>  Programming Code  >>  C Code
 
 


 

 
 C Code interview questions  C Code Interview Questions
 C++ Code interview questions  C++ Code Interview Questions
 VC++ Code interview questions  VC++ Code Interview Questions
 Java Code interview questions  Java Code Interview Questions
 Dot Net Code interview questions  Dot Net Code Interview Questions
 Visual Basic Code interview questions  Visual Basic Code Interview Questions
 Programming Code AllOther interview questions  Programming Code AllOther Interview Questions
Question
What is the main difference between STRUCTURE and UNION?
 Question Submitted By :: Mariaalex007
I also faced this Question!!     Rank Answer Posted By  
 
  Re: What is the main difference between STRUCTURE and UNION?
Answer
# 1
All the members of the structure can be accessed at
once,where as in an union only one member can be used at a time.
Another important difference is in the size allocated to a
structure and an union.
for eg:
struct example
{
  int integer;
  float floating_numbers;
}
the size allocated here is sizeof(int)+sizeof(float);
where as in an union
union example
{
  int integer;
  float floating_numbers;
}
size allocated is the size of the highest member.
so size is=sizeof(float);
 
Is This Answer Correct ?    16 Yes 1 No
Vijay Nag
 
  Re: What is the main difference between STRUCTURE and UNION?
Answer
# 2
1) Structure: The size in bytes is the sum total of size of 
all the elements in the structure, plus padding bytes.
2) Size of in bytes of the union is size of the largest 
variable element in the union. 

i.e In case of Union, the elements making up the 
union 'overlap' in memory OR they are accessed as diffrent 
name/type at diffrent places in the program.

Whereas in case of Struct, each of the elements have a 
distinct identity.
 
Is This Answer Correct ?    7 Yes 1 No
Ravi
 
 
 
  Re: What is the main difference between STRUCTURE and UNION?
Answer
# 3
The difference between structure and union in c are: 1. 
union allocates the memory equal to the maximum memory 
required by the member of the union but structure allocates 
the memory equal to the total memory required by the 
members. 2. In union, one block is used by all the member 
of the union but in case of structure, each member have 
their own memory space
 
Is This Answer Correct ?    2 Yes 0 No
Dinesh Haridoss
 

 
 
 
Other C Code Interview Questions
 
  Question Asked @ Answers
 
print numbers till we want without using loops or condition statements like specifically(for,do while, while swiches, if etc)!  7
Find your day from your DOB? Microsoft12
Given n nodes. Find the number of different structural binary trees that can be formed using the nodes. Aricent3
Write a prog to accept a given string in any order and flash error if any of the character is different. For example : If abc is the input then abc, bca, cba, cab bac are acceptable, but aac or bcd are unacceptable. Microsoft4
String reverse with time complexity of n/2 with out using temporary variable. NetApp7
How will u find whether a linked list has a loop or not? Microsoft3
plz send me all data structure related programs  2
Given a list of numbers ( fixed list) Now given any other list, how can you efficiently find out if there is any element in the second list that is an element of the first list (fixed list) Disney2
Finding a number multiplication of 8 with out using arithmetic operator NetApp7
Sorting entire link list using selection sort and insertion sort and calculating their time complexity NetApp1
programming in c lanugaue programm will errror error with two header file one as stdio.h and other one is conio.h  1
Given an array of characters which form a sentence of words, give an efficient algorithm to reverse the order of the words (not characters) in it. Microsoft4
How we will connect multiple client ? (without using fork,thread) TelDNA2
Link list in reverse order. NetApp7
1) int i=5; j=i++ + i++ + i++; printf("%d",j);This code gives the answer 15.But if we replace the value of the j then anser is different?why? 2)int i=5; printf("%d",i++ + i++ + i++); this givs 18. Infosys3
write the function. if all the character in string B appear in string A, return true, otherwise return false. Google7
how to check whether a linked list is circular.  3
Write a routine that prints out a 2-D array in spiral order Microsoft2
How to read a directory in a C program?  3
Write a function to find the depth of a binary tree. Adobe4
 
For more C Code Interview Questions Click Here 
 
 
 
 
 
   
Copyright Policy  |  Terms of Service  |  Help  |  Site Map 1  |  Articles  |  Site Map  |   Site Map  |  Contact Us interview questions urls   External Links 
   
Copyright © 2007  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  Forum9.com   ::  KalAajKal.com