GATE / CS ARCHIVE

GATE CSE 2000 / QUESTION 1.11

Reading an array-of-pointers declaration

Programming in C · Structures & Declarations · Full GATE CSE 2000 paper

GATE 2000, Q1.11 1 mark · MCQ
Report issue

Structures & Declarations

Question 1.11, GATE 2000: Given struct node with int i and float j, followed by struct node *s[10], what is s: array of structure pointers, two-field structure of arrays, three-field structure, or array of structures?
Tap to enlarge
Your answer
Answer & solution

Answer: A (no official key was published)

Step 1: Read outward from s. The immediately attached [10] makes s an array of ten elements.

Step 2: The preceding * says each element is a pointer, and the base type struct node says what it points to. Thus s is an array of ten pointers to nodes, A.

The node’s two fields describe each pointed-to object, not extra fields inside s. Writing struct node s[10] without * would instead produce the array of structures in D.

Original paper, page 2