Declaring variables with const

I think 'const 'stands for constant

i think const is a command that tells the code to never change the variable under any circumstance and as the name states , is too keep the variable constant

A const is a data bucket that can not be changed. A good example is a persons date of birth.

I assume const to represent constant. Using this in conjunction with a variable would turn the variable into a fixed value integer? I think it would keep the value constant even if attempting to change it later in the code.

1 Like

A constant variable (as ā€œconstā€ implies), is a variable whose value remains constant throughout its life. If we try to modify it, we will get an error.

1 Like

To make it a constant value, no matter the changes we try to make further down the code.

1 Like

It stands for ā€œConstantā€ and I can only think that it means that the value will constantly stay the same value as you inserted.

1 Like

When putting the keyword const in front of a variable we declare that we never want to change its value during run time. We do not want user input nor calculations made by functions in the program to alter the values. In other words the value of a cconstant ie a variable proceeded by keyword const cannot be changed.

//
Ingeborg

1 Like

Const does not allow any changes to a variable that you want to assign.

1 Like

i believe this will make the variables with const in front of them be made to where they cannot be changed.

1 Like

const is a keyword that will not allow you to change the value of the variable any further

1 Like

Const seems to mean ā€œconstantā€ and the best way I can think of how it works is that it keeps the variable the same throughout the code?

A const keeps a variable the same throughout the function.

I think const means that the value of the variable canĀ“t change. In other words, turns a variable into a constant.

I understand declaring a variable to be const as a way to ensure itā€™s value wonā€™t be changed.

Const, from what I believe is short for constant. Meaning its value will be constant, never changing. It will remain the same no matter what.

I think that it simply means that the variable cannot be changed or you will get an error.

Hello,

Iā€™m guessing const is short for constant, which is something that is unchanging. The mathematical definition of constant means non varying.

Iā€™m predicting that using const in front of the int variable locks it into its original value.

Since int is short for integer, I would guess const stands for constantā€¦ so that value can never be changed.

I think const makes the variable constant, and prevents it from being affected / changed by other code. Shot in the dark :slight_smile:

Privacy & Terms