Question 66

Computer Awareness Data Structure Medium

What happens if the following program is executed in C and C++? \[\]int main(void) { \[\]int new = 1; \[\]printf("%d", new);\[\] }

(A) Error in both C and C++
(B) A successful run in both C and C++
(C) Error in C and successful execution in C++
(D) Error in C++ and successful execution in C
View Dynamic Solution & Explanation
Correct Solution: Option D

Step-by-step Solution:

In C, `new` is not a keyword, so the code runs successfully.
In C++, `new` is a reserved keyword, causing a compilation error.
Answer: D. Error in C++ and successful execution in C.