Which statement correctly describes int *p[5] in C++?

Options

  • A. It is a pointer to an array of five integers
  • B. It is an array of five pointers to integers
  • C. It is a five-dimensional integer array
  • D. More than one of the above
  • E. None of the above

Correct Answer (Detailed Explanation is Below)

B. It is an array of five pointers to integers

Detailed Explanation

Answer: (B) It is an array of five pointers to integers

The declaration int *p[5]; should be read carefully.

The brackets [5] bind more closely to p, so p is an array of 5 elements.

Each element of this array is an int*, meaning a pointer to an integer.

Therefore:

int *p[5]; → array of five pointers to int.