The Wayback Machine - https://web.archive.org/web/20240118170514/https://www.geeksforgeeks.org/c-const-keyword-question-5/
Open In App
Related Articles

C++ | const keyword | Question 5

Improve
Improve
Improve
Like Article
Like
Save Article
Save
Report issue
Report

Output of C++ program?




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


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

Learn to code easily with our course Coding for Everyone. This course is accessible and designed for everyone, even if you're new to coding. Start today and join millions on a journey to improve your skills!

Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out - check it out now!

Commit to GfG's Three-90 Challenge! Purchase a course, complete 90% in 90 days, and save 90% cost click here to explore.
Last Updated : 28 Jun, 2021
Like Article
Save Article
Share your thoughts in the comments
Similar Reads