In C++, which of the following statements correctly returns the memory from…

2017

In C++, which of the following statements correctly returns the memory from the dynamic array pointer pp to the free store?

  1. A.

    delete pp;

  2. B.

    delete pp [ ];

  3. C.

    delete [ ] pp;

  4. D.

    *delete pp;

Attempted by 225 students.

Show answer & explanation

Correct answer: C

Key point: Always match allocation and deallocation: use delete for memory allocated with new, and delete[] for memory allocated with new[]. Correct syntax for freeing a dynamic array is delete[] pp;. Example: int* pp = new int[10]; delete[] pp;

A video solution is available for this question — log in and enroll to watch it.

Explore the full course: Uppsc Polytechnic Lecturer 2025 Cs