Declaring variables with const

Maybe it will allow us to be able to make changes to the integers without having to be constrained to the location of the code in the editor?

the variable becomes a constant

It probably makes it so that the integer (or any other data type, for that matter?) can only be read and not modified.

I suppose const is an instruction to keep the declared variable static or unchanged from the initial declared value i.e const int a = 4 would keep the variable at 4 possibly even after declaring an alternative value for ‘a’.

From my previous small java experience, I think const means a constant, which shows that the integer is constant, aka not changeable. It might even throw up an error if we try to set it to a new value.

I think const doesn’t allow change to your variable keeping it constant.

the const keyword means that the value will be constant and can’t change during runtime.

I think const as a keyword before int makes it so that the value of the variable will always be to its initialized value. The value cannot be changed when attempting to assign the variable to a new value.

I think const is (short for constant) used to keep the int value the same.

I am guessing the const keeps the variable constant. so that is can not change in the code later on.

1 Like

It seems to be some abreviation of the word “constant”. I think we use it when we don’t want something to change, maybe not allow a later change in the variable’s value.

It seems like the ‘const’ tag before the int data type will cause whatever value that is placed after the initializer (=) to be inseparably connected to the identifier of that integer.

It is something that refers to a value that can not be changed anymore.Once it is declared as a constant and you initialize it with a data then it is irreversible i mean it can not be changed.

i think const lets the compiler know that this value will not and should not be able to change

I think that a const is a constant, and a constant is a word for something that stays the same, so it probably means a variable that stays the same.

I thought that when you used the keyword “const” the variable wouldn’t be able to change, because now it was a constant instead of a variable, so I put it in practice and the terminal confirmed my thoughts.

So I think that const means constant just like many others and I think in computer language it means a variable that won’t change.

it declares the integer put in as a constant and not a variable, hence we cant change it value at any point after it has been declared

I think Const is a constant value for a variable. it cannot be changed. Even if attempted it will reset or maybe it will flash an error during compiling. AM I CORRECT?

The const keyword allows you to protect a variable against change from the active part of a program
numerically this could be a persons national insurance number or string wise it could be their name.

Privacy & Terms