The Wayback Machine - https://web.archive.org/web/20240407022828/https://www.geeksforgeeks.org/c-const-keyword-question-4/
Open In App

C++ | const keyword | Question 5

Last Updated : 28 Jun, 2021
Like Article
Like
Save
Share
Report




#include <stdio.h>
int main()
{
   const int x;
   x = 10;
   printf("%d", x);
   return 0;
}


(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


Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads