C++ | const keyword | Question 5

Output of C++ program?

filter_none

edit
close

play_arrow

link
brightness_4
code

#include <iostream>
int const s=9;
int main()
{
    std::cout << s;
    return 0;
}

chevron_right


Contributed by Pravasi Meet
(A) 9
(B) Compiler Error


Answer: (A)

Explanation: The above program compiles & runs fine. Const keyword can be put after the variable name or before variable name. But most programmers prefer to put const keyword before the variable name.

Quiz of this Question



My Personal Notes arrow_drop_up


Article Tags :
Practice Tags :


Be the First to upvote.


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