N Như Quỳnh New member Sep 18, 2021 #1 What happens if the following line is executed in C and C++? Code: const int a; A. Error in both C and C++ B. Warning in both C and C++ C. Error in C and successful execution in C++ D. Error in C++ and successful execution in C
What happens if the following line is executed in C and C++? Code: const int a; A. Error in both C and C++ B. Warning in both C and C++ C. Error in C and successful execution in C++ D. Error in C++ and successful execution in C
N Nguyễn Hào New member Sep 18, 2021 #2 Answer: d Explanation: C++ compiler does not allow the programmer to declare a constant variable without initializing it hence the C++ compiler gives an error whereas C allows such declaration, therefore, the program compiles and runs successfully. Upvote 0 Downvote
Answer: d Explanation: C++ compiler does not allow the programmer to declare a constant variable without initializing it hence the C++ compiler gives an error whereas C allows such declaration, therefore, the program compiles and runs successfully.