+1 vote
in C Plus Plus by

What happens if the following C++ statement is compiled and executed?

int *ptr = NULL;
delete ptr;

a) The program is not semantically correct
b) The program is compiled and executed successfully
c) The program gives a compile-time error
d) The program compiled successfully but throws an error during run-time

1 Answer

0 votes
by

Answer: b
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.

Related questions

+1 vote
asked Oct 19, 2022 in C Plus Plus by AdilsonLima
0 votes
asked May 21, 2020 in JAVA by GeorgeBell
...