How can a constant be a variable?

I don't quite see that
Mark S.

const int x = 5;
int y;

x is a variable like pi (3.14159), it does not change.
y is a variable that can change (y = voltage on A0)

.

markba633csi:
I don't quite see that
Mark S.

What confuses you about a named value that does not change? In math you have a name for the ratio of a circle's circumference to its diameter: Pi. In physics you have various constants like "C" (the speed of light).

Is it the fact it is called a "variable" but then it isn't being allowed to vary what is confusing?

As implied:
E = MC2

C = 299,792,458 m/s

'C' is a variable that does not change.

The term "variable" means a name associated with a memory location. It does NOT mean (though the name does seem to imply that it does) that the value in the memory location can be changed at will.

"symbolic reference" is a more generic term that covers both variables and constants.

I have 10 variables which are defined in the following array:

byte myArray[] = {0x3F, 0x06, 0x5B, 0x4F, 0x66, 0x6D, 0x7D, 0x07, 0x7F, 0x6F};

The array is initialized in RAM space of the MCU. I know very well about the nature of the elements of the array which are cc(common cathode codes) for the decimal digits: 0, 1, ..., 8, 9. I also know that the values of the array elements will remain as they are through out the whole life of the executing program. So, I wish to make the array elements 'Read-only' in order to give them some kind of 'Pseudo Protection' so that they can't be inadvertently written and corrupted. The compiler/programming language has told us to do it just by putting the attribute const for constant.

The mechanism of protecting data/code in RAM area has been elaborately explained in the Protected Mode Operation (PVAM) of Intel High Performance 80286/80386 architectures
//-------------------------------------------------------------------------------

const byte myArray[]=  {0x3F, 0x06, 0x5B, 0x4F, 0x66, 0x6D, 0x7D, 0x07, 0x7F, 0x6F};

myArray[0] = 0x23;   // attempt to change value; it is not allowed; there is a compilation error

//-------------------------------------------------------------------------------

byte myArray[]=  {0x3F, 0x06, 0x5B, 0x4F, 0x66, 0x6D, 0x7D, 0x07, 0x7F, 0x6F};

myArray[0] = 0x23;         // attempt to change value; it is allowed; there is no compilation error

The mechanism of protecting data/code in RAM area has been elaborately explained in the Protected Mode Operation (PVAM) of Intel High Performance 80286/80386 architectures

The above has nothing what so ever to do with C/C++ constants.

The idea of a constant dates back to at least the 1950's. In a typical programming language it is enforced by the compiler at compile time and totally forgotten by runtime.

Mark

evanmars:
Is it the fact it is called a "variable" but then it isn't being allowed to vary what is confusing?

That's language. It's messy and illogical, always has been and always will be.

Evanmars got my drift; the nomenclature was/is a little hard to grasp at first.
Mark S.
ps It took me a while to understand = vs == also

markba633csi:
Evanmars got my drift; the nomenclature was/is a little hard to grasp at first.
Mark S.
ps It took me a while to understand = vs == also

Also watch out for || vs |, && vs &, ++x and --x vs x++ and x--, etc.