What is const in cpp? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

What is const in cpp?

8th Mar 2019, 1:55 PM
Akash Gite
Akash Gite - avatar
3 Answers
+ 7
A constant is an expression with a fixed value. It cannot be changed while the program is running. Use the const keyword to define a constant variable. https://www.sololearn.com/learn/CPlusPlus/1895/
8th Mar 2019, 2:06 PM
JTLZ
+ 1
For example const float pi = 3.14; As you don't want to change value any time during the execution this won't let you do it by mistake.
8th Mar 2019, 2:10 PM
Sahil Bhakat
Sahil Bhakat - avatar
0
If we declare value as a const in a program we can't change that value, That value is fixed value in that program
28th Dec 2019, 5:08 PM
Varsha Gadhe
Varsha Gadhe - avatar