Complete the code to allocate memory for an integer using new.
int* ptr = [1] int;In C++, new is used to allocate memory dynamically.
Complete the code to deallocate memory allocated for an integer pointer.
delete [1];Use delete followed by the pointer variable to free memory.
Fix the error in the code to allocate an array of 5 integers.
int* arr = [1] int[5];
Use new with square brackets to allocate arrays: new int[5].
Fill both blanks to correctly deallocate the array allocated with new.
delete[1] [2];
Use delete[] followed by the pointer to free arrays allocated with new[].
Fill all three blanks to allocate memory for a double, assign a value, and then deallocate it.
double* [1] = [2] double; *[1] = 3.14; delete [3]; [1] = nullptr;
First declare pointer ptr, allocate with new, assign value, then delete ptr.
