Structure & Union Questions and Answers

Practice Mode
Showing 10 of 95 questions
Q71
Find the output union india { int i; char ch[2]; } orissa; void main ( ) { orissa.ch[0]=1; orissa.ch[1]=2; printf("%d", orissa.i); }
  • A 513
  • B 257
  • C 21
  • D 12
Answer: Option A
Q72
Find the output union abc { int x; char c; struct str { int a; char b; char c; }p; }q; void main ( ) { printf('%d", sizeof(q)); }
  • A 2
  • B 4
  • C 7
  • D Compiltion error
Answer: Option B
Q73
Find the output union xxx { int x; float y; }xx; void func(union xxx x); void main ( ) { xx.x=10; xx.y=3.14; func(xx); printf("%d", xx.x); } void func (union xxx xx { xx.x=20; printf("%d", xx.x); return; }
  • A Garbage Garbage
  • B 20 Garbage
  • C Garbage 20
  • D Compilation error
Answer: Option B
Q74
Find the output union sbi { int i; char ch[2]; }; void main ( ) { union sbi idco={127}; printf('%d %d%d", idco.i, idco.ch[0], idco.ch[1]); }
  • A 127 127 0
  • B 127 127 127
  • C 127 Garbage Garbage
  • D 127 127 Garbage
Answer: Option A
Q75
Find the output. union uni { int x; char y; }; void main ( ) { union uni u; u.x =90; printf("%c", u.y); }
  • A 9
  • B Z
  • C Compilation error
  • D None of these
Answer: Option B
Q76
Find the output union res { char a:6; int b:8; }; void main ( ) { union res s; pintf("%d", sizeof (s)); }
  • A 14
  • B 8
  • C 1
  • D 2
Answer: Option D
Q77
Find the output. union res { int a:16; char b:10; }; void main ( ) { union res s; s.b='B'; s.a=10; printf('%c%d", s.b, s.a); }
  • A 2048 10
  • B B 2144
  • C B 10
  • D Compilation error
Answer: Option D
Q78
Find the output union uni int x; int a:8; char b:8; }; void main ( ) { union uni u={48}; printf('%d %d", u.a, u.b); }
  • A Invalid initialization
  • B 48 0
  • C 48 48
  • D 0 0
Answer: Option B
Q79
Find out the true statement.
  • A A union variable can be assigned to another union variable.
  • B The address of union variable can be extracted by using & operator.
  • C A function can return a pointer to the union
  • D All of the above
Answer: Option D
Q80
Which member of a union is in use at any time can be known explicitly using
  • A Enum
  • B Bit fields
  • C Static members
  • D Can't be determined
Answer: Option D
Questions and Answers for Competitive Exams Various Entrance Test