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 type or before variable type. But most programmers prefer to put const keyword before the variable type.

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

Improved By : iloat

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.