VKV SirTest Lab

Structures and Unions: viva questions and MCQs

Computer Programming Lab (C), Unit 9. 100+ Structures and Unions questions with explanations (Computer Programming Lab (C)). Topics: C Structs, C Structs Output. Take a free test now.

Topics

Key terms: structure, member, little endian, plus padding, keyword, pointer, double bytes, assuming, char float, float double, padding sizeof, struct

Sample questions with answers

  1. struct pt { int x, y; } p = {5, 6}; printf("%d", p.x * p.y); prints:

    Options: A) 6   B) 30   C) 11   D) 5

    Answer: B) 30. Members accessed with the dot operator.

  2. struct pt { int x, y; } p = {9, 2}; printf("%d", p.x - p.y); prints:

    Options: A) 7   B) -7   C) 9   D) 2

    Answer: A) 7. Members accessed with the dot operator.

  3. In C, "Nested structure" means:

    Options: A) Accesses a member of a structure variable, e.g. s.roll   B) A structure that contains another structure as a member   C) Structure member with a specified number of bits   D) User-defined type whose members share the same memory location

    Answer: B) A structure that contains another structure as a member. Nested structure: A structure that contains another structure as a member.

Take a free Structures and Unions test

All units of Computer Programming Lab (C)