C++ | const keyword | Question 5
#include <stdio.h> int main() { const int x; x = 10; printf("%d", x); return 0; } |
chevron_right
filter_none
(A) Compiler Error
(B) 10
(C) 0
(D) Runtime Error
Answer: (A)
Explanation: One cannot change the value of ‘const’ variable except at the time of initialization. Compiler does check this.
Quiz of this Question
Recommended Posts:
- C++ | const keyword | Question 1
- C++ | const keyword | Question 5
- C++ | const keyword | Question 2
- C++ | const keyword | Question 3
- Function overloading and const keyword
- Difference between const int*, const int * const, and int const *
- Difference between const char *p, char * const p and const char * const p
- C++ | Static Keyword | Question 6
- C++ | Static Keyword | Question 4
- C++ | Static Keyword | Question 1
- C++ | Static Keyword | Question 5
- C++ | Static Keyword | Question 2
- C++ | Static Keyword | Question 3
- C++ | friend keyword | Question 1
- C++ | friend keyword | Question 2



