Register Now

Login

Lost Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

What happens if the following C++ statement is compiled and executed?
int *ptr = NULL;
delete ptr;

What happens if the following C++ statement is compiled and executed?
int *ptr = NULL;
delete ptr;
a) The program compiled successfully but throws an error during run-time
b) The program gives a compile-time error
c) The program is not semantically correct
d) The program is compiled and executed successfully

Answer: d
Explanation: The above statement is syntactically and semantically correct as C++ allows the programmer to delete a NULL pointer, therefore, the program is compiled and executed successfully.

Join The Discussion