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
- C Structs: structure, member, little endian, plus padding, keyword, pointer, typedef, declared
- C Structs Output: double bytes, assuming, char float, float double, padding sizeof, struct, bytes sizeof, sizeof union
Key terms: structure, member, little endian, plus padding, keyword, pointer, double bytes, assuming, char float, float double, padding sizeof, struct
Sample questions with answers
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.
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.
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.