Declaring variables with const

I think const makes the variable constant as in the value is assigned to a variable only one time and it cannot be changed.

The const keyword stands for ā€œconstantā€, which means when we declare a variable with this keyword, it cannot be changed after initialization. Constant variables need to be initialized after declarement.

const refers to keeping the variable a constant, so the value cannot redeclared and changed

I felt like it was short for constant, but didnā€™t know what it would mean. Reading through these comments is insightful bc even though I know it will be explained in a few moments, seeing how others think about it helps train my brain to think about these problems/questions in a different way

the const does is
to prevent any variabel to modifying, so it means that we canā€™t change a variable that already assign before with const but if we didnā€™t type const on variabel we can change it.

CONST is constant, so, I think const is a way to declare a variable that never will change its value.

I imagine that it forces the compiler to stick with whatever value was assigned when we used the ā€œconstā€ keyword, even if we re-change the variable later down the line.

const int = constant. BOOM! POW!

1 Like

I think it will declare that the value assigned to the variable is constant and cannot be changed.

Const will not allow the user to modify the variableā€™s value after it has been declared

1 Like

const means that it is constant. Thus the value cannot be changed.

1 Like

Const declares a variable as constant. It cannot be modified after initialization.

1 Like

Iā€™m guessing const prevents the variable from changing

1 Like

It makes the variable constant within int main function

1 Like

declaring variables using const int will never allow us to re-assign the value of the declared variable. while using int without const will allows us to re-assign the values which may be usefull in few conditions but not on few conditions which may change the game logic in my view.

1 Like

Const is keyword in C++ language which stands for constant. It is used to make a constant variable, These constant variable does not change there value throughout the program (i.e they remain constant ).

Const is something that sets variableā€™s content to something constant which means that it cannot be changed later on.

1 Like

Const is a keyword used to represent a constant. the value assigned to a variable with const cannot be changed later on. i.e their value cannot be changed later on in the code.

I think that const means that a variable becomes unchangeable, so even with a further attempt to change this variable ā€œes: a = 7ā€ it give us an error.

I believe it makes it so the variableā€™s number cannot be redefined

1 Like

Privacy & Terms