Which statement correctly allocates an array of 10 integers dynamically in C++?

Options

  • A. int *p = new int[10];
  • B. int *p = new int(10);
  • C. int p = new int[10];
  • D. More than one of the above
  • E. None of the above

Correct Answer (Detailed Explanation is Below)

A. int *p = new int[10];

Detailed Explanation

Correct Answer: Option A

Explanation: new int[10] allocates an array of 10 integers and returns a pointer to its first element. By contrast, new int(10) allocates one integer initialized to 10.