Structure & Union Questions and Answers

Take Exam

Structure & Union Questions with Answers are key topics in C programming questions and answers sections of competitive exams and technical interviews. These concepts allow efficient memory usage and data management, making them essential for understanding advanced C applications. Commonly featured in TCS, Infosys, and Tech Mahindra placement tests, questions on structure and union test your ability to differentiate between memory allocation, member access, and implementation. Practicing C programming MCQs with explanations improves conceptual clarity and debugging skills. Start your preparation with our curated C Structure & Union MCQs and download free PDFs for revision.

Structure & Union

Showing 10 of 95 questions

81. 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); }

  • 50 2 2
  • 50 garbage garbage
  • 50 50 50
  • 50 2 garbage
Show Answer Report

82. 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)); }

  • 4
  • 10
  • 16
  • Error, too many types in declaration
Show Answer Report

83. State the correct statement

  • Union declaration reservesd memory but definition doesn't.
  • Structure declaration reserves memory but definition doesn't
  • Data members of structure are private by default.
  • None of the above
Show Answer Report

84. 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); }

  • 10
  • 97
  • Garbage output
  • Compilation error
Show Answer Report

85. Which is not possible with union ?

  • Array of union
  • Pointer to union
  • Self-referential union
  • None of the above
Show Answer Report

86. Find the output #define MAX int a union uuu { MAX; float b; }; void main ( ) { union uuu u={5.5}; printf('%d", u.a); }

  • 5.0
  • 5
  • Compilation error
Show Answer Report

87. 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;

  • p=p+sizeof(choice.x);
  • p=p+sizeof)*p);
  • p=(void*)((union choice *) p+a);
  • p=(void*)(union choice *)p;
Show Answer Report

88. 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); }

  • iija
  • iaja
  • jaja
  • None of these
Show Answer Report

89. Find the output union abc { int ; float f; }ab; void main ( ) { ab.i=23.567; printf('%f", ab.f); }

  • 23.567
  • 23.0000
  • suffering
  • None of these
Show Answer Report

90. Find the output union uni { int x; char: 8; }; void main ( ) { union uni u={64}; printf("%c"); }

  • A
  • Garbage
  • Declaration terminated incorrectly
  • None of these
Show Answer Report
Questions and Answers for Competitive Exams Various Entrance Test