Union in C Language

Programming Language > C Programming Language

Union is an user defined datatype in C programming language. It is a collection of variables of different datatypes in the same memory location. We can define a union with many members, but at a given point of time only one member can contain a value. Unions can be very handy when you need to talk to peripherals through some memory mapped registers. ➲ Union in C Language - Quiz


  • A All of them let you define new values
  • B All of them let you define new data types
  • C All of them let you define new pointers
  • D All of them let you define new structures
  • A First member in the union
  • B Last member in the union
  • C Biggest member in the union
  • D Sum of the sizes of all members
  • A Will be large enough to hold the largest of the three types;
  • B Will be large enough to hold the smallest of the three types;
  • C Will be large enough to hold the all of the three types;
  • D None of the mentioned
  • A union-name.member
  • B union-pointer->member
  • C both union-name.member & union-pointer->member
  • D none of the mentioned
  • A *symtab[i].u.sval
  • B symtab[i].u.sval[0].
  • C You cannot have union inside structure
  • D Both *symtab[i].u.sval & symtab[i].u.sval[0].
  • A 1, 2, 13
  • B 1, 4, 4
  • C -1, 2, -3
  • D -1, -2, -13
  • A 1
  • B 2
  • C 4
  • D 9
  • A Compile time error
  • B sizeof(int) + sizeof(char)
  • C Depends on the compiler
  • D sizeof(int)
  • A Compile time error
  • B sizeof(int) + sizeof(char)
  • C Depends on the compiler
  • D sizeof(char)
  • A Compile time error
  • B Implementation dependent
  • C 10.000000
  • D 0.000000