C Programming Question and Answers

9. What is the difference between structure and union?
 
  • 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.
  • In union, one block is used by all the member of the union but in case of structure, each member has their own memory space.
  • Union is best in the environment where memory is less as it shares the memory allocated.
  • But structure cannot implement in shared memory.
  • As memory is shared, ambiguity is more in union, but less in structure.
  • Self referential union cannot be implemented in any data structure, but self referential structure can be implemented.
 
Your Name Your Email-ID
Your Answer
10. What is variable in C?
 
  • Program can manipulate the data.
  • This location is used to hold the value of the variables.
  • C variable might be belonging to any of the data type like int, float and char etc.
  • The value of the C variable may get change in the program.
 
Your Name Your Email-ID
Your Answer
11. What is the default statement used in switch case in C?
 
  • Switch case statements are used to execute only specifies case statements based on the switch expression.
  • If switch expression does not match with any case, default statements are executed by the program.
 
Your Name Your Email-ID
Your Answer
12. What is the restriction on the declarations and/or definitions of variables?
  The restriction on the declarations and/or definitions is that they must come before the executable statements in a block, and hence they appear in the beginning of a block.
 
Your Name Your Email-ID
Your Answer
123456789101112


131415 Page 3 of 15