Structure & Union Questions and Answers

Practice Mode
Showing 10 of 95 questions
Q81
Find the output union unit { int x; char y; }; union neon { union unit u; char ch; }; void main ( ) { union neon n={50}; printf("%d %c %c", n.u.x, n.ch, n.u.y); }
  • A 50 2 2
  • B 50 garbage garbage
  • C 50 50 50
  • D 50 2 garbage
Answer: Option A
Q82
Find the output union uuu { struct student { int roll; char name [10]; float percentage; }; float sal; }; void main ( ) { union uuu u; printf('%d", sizeof (u)); }
  • A 4
  • B 10
  • C 16
  • D Error, too many types in declaration
Answer: Option D
Q83
State the correct statement
  • A Union declaration reservesd memory but definition doesn't.
  • B Structure declaration reserves memory but definition doesn't
  • C Data members of structure are private by default.
  • D None of the above
Answer: Option D
Q84
Find the output union un { int x; char y; float z; }; void main ( ) { union un *u; u=(union un*) malloc (sizeof(union un)); u->x=10; u->'a' printf("%d", u->x); }
  • A 10
  • B 97
  • C Garbage output
  • D Compilation error
Answer: Option B
Q85
Which is not possible with union ?
  • A Array of union
  • B Pointer to union
  • C Self-referential union
  • D None of the above
Answer: Option A
Q86
Find the output #define MAX int a union uuu { MAX; float b; }; void main ( ) { union uuu u={5.5}; printf('%d", u.a); }
  • A 5.0
  • B 5
  • C Compilation error
Answer: Option B
Q87
Which of the following is used to increment the pointer "p" to next member of the array? union choice { int x[10]; float f[10]; }; union choice colour[15]; void *p=colour;
  • A p=p+sizeof(choice.x);
  • B p=p+sizeof)*p);
  • C p=(void*)((union choice *) p+a);
  • D p=(void*)(union choice *)p;
Answer: Option C
Q88
Find the output union xyz { char name [10]; char x; }; void main ( ) { union xyzp={"raja")}; p.x='i\r'; p.x='ij'; printf("%s", p.name); }
  • A iija
  • B iaja
  • C jaja
  • D None of these
Answer: Option B
Q89
Find the output union abc { int ; float f; }ab; void main ( ) { ab.i=23.567; printf('%f", ab.f); }
  • A 23.567
  • B 23.0000
  • C suffering
  • D None of these
Answer: Option C
Q90
Find the output union uni { int x; char: 8; }; void main ( ) { union uni u={64}; printf("%c"); }
  • A A
  • B Garbage
  • C Declaration terminated incorrectly
  • D None of these
Answer: Option A
Questions and Answers for Competitive Exams Various Entrance Test