0 votes
in C Plus Plus by

What happens if the following program is executed in C and C++?

#include <stdio.h> 
int main(void) 
{ 
	int new = 5;
	printf("%d", new); 
}

a) Error in C and successful execution in C++
b) Error in both C and C++
c) Error in C++ and successful execution in C
d) A successful run in both C and C++

1 Answer

0 votes
by

Answer: c
Explanation: new is a keyword in C++, therefore, we cannot declare a variable with name new but as there is no such keyword new in C, therefore, the program is compiled and executed successfully in C.

Related questions

+1 vote
asked Oct 19, 2022 in C Plus Plus by AdilsonLima
0 votes
asked Dec 21, 2023 in C Plus Plus by GeorgeBell
...