I said before that variables are locations in memory of certain size because of that type and those
variables can change using the assignment operator or addition or other operators.
But a lot of the time we want something that's just completely constant all the time and we never want
it to change.
So let's see how we can do this.
So there's something in C++ called the conc keyword.
And let's make a conc constant for pi.
Hi.
So we say Konst float Pi three point 1 4 1 5 9.
Say OK.
And so our convention for constants naming the constants will always be uppercase letters and if we
have multiple words we'll use underscores.
So let's say two pi would be two times this say.
For now we're CAN going to use pi so see a complete example with this.
So let's say float radius in c c h.
These enter the radius of a circle
in radius C..
Come brunette's the circle is
two times pi times the radius
k.
So run this
say 10.
So the circumference is 62 point three you on it.
So notice how we can use pi after you'd find it in other places in say error arithmetic operations.
And I said before that it's constant.
So let's try to actually change PI rate here and see what happens.
So we actually got an error so it says hey you can't just add 1 to pi because it's constant to read
only variable and not assignable as it says in gcc.
So it really is conc and we can't change it.
So you may ask why would we ever need constants.
Why can't we just put three point 1 4 1 5 here instead.
Well say if we use pi in many places in the code but for some reason we had to change it to make it
more or less precise let's say we would only need to change it here in this one place.
And then all the other places that use pi would get that change.
So that's one reason why we always want to use constants.
If they apply to our situation I never want to see what's called Magic Numbers which is just say we
had instead of Pi we had three point 1 4 here and this is this three point four is really just a magic
number.
We don't really know what it is or what it represents and really constants are a good way to make code
more readable and understandable.
So that's why we use it.
So we're always going to use constants where appropriate unless something like zero we don't need a
constant effort for this for example doesn't that doesn't really matter too much.
So we'll be using the concepts he word in actually in a few different ways in the next sections.