C++ | const keyword | Question 5

filter_none

edit
close

play_arrow

link
brightness_4
code

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

chevron_right


(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

Don’t stop now and take your learning to the next level. Learn all the important concepts of Data Structures and Algorithms with the help of the most trusted course: DSA Self Paced. Become industry ready at a student-friendly price.

My Personal Notes arrow_drop_up
Article Tags :
Practice Tags :


1


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.