What is const qualifier? - C++

What is const qualifier? Explain with an example.

- The qualifier const can be applied to the declaration of any variable to indicate that its value will not be changed. Once a variable is declared with const qualifier, it no longer remains a variable (i.e. its value can not be changed). A const must be initialized with some value.
- Example :
const TYPE x = 10; //where TYPE is any data type.
const int x = 5; // This will define x as constant with value 5
- Note that once const is defined, its value can not be changed by arithmetic operations or assignment.

What is const qualifier?

const qualifier is used to specify the variable that can’t be change throughout the program. Variable with const qualifier is often named in uppercase.
Describe Selection – if and switch using C++
Describe Selection – if and switch using C++ - if is decision making control and its general for is:...
Explain Loops – While loop, Do-while loop, for loop
Explain Loops – While loop, Do-while loop, for loop - Loops are used to carry out certain instruction(s) in continuation for a fixed no of times.....
What are Vectors and Deques?
What are Vectors and Deques? - Vector is one type of standard container provided by C++ library...
Post your comment