Question 23

What is the meaning of the following declaration in C programming language?

What is the meaning of the following declaration in C programming language? int (*p) [5];
  1. AIt will result in compile error because there should not be any parenthesis, i.e., "int*p[5]" is valid
  2. Bp is a pointer to 5 integers
  3. Cp is a pointer to integer array
  4. Dp is a pointer to an array of 5 integers
Show answerHide answer

Correct answer: (D) p is a pointer to an array of 5 integers

Explanation

The parentheses bind * to p first, so p is a pointer, and that pointer points to an array of 5 ints. Without parentheses, int *p[5] would be an array of 5 pointers to int.

From DSSSB TGT Computer Science Practice Set 3

This is question 23 of DSSSB TGT Computer Science Practice Set 3. See all questions of this paper with answers, or attempt the paper as a timed online test to get your score and all-India rank.