In the last section we looked at a few examples of variables and applied them into our hello world example. But what if you want to store a value and ensure it cannot be altered? For that, you would need a constant.
A constant is declared and initialized in much the same way as a variable, but is preceded by the keyword, const. For example:
const float total = 95.1;
Here we have a float type constant named “total” with a value of 95.1. Once initialized, the value of total cannot be modified and attempts to assign a new value to the constant will be met with an error message in the build window.