2.2.4 Constant Variables

Constant variables are declared using the const keyword, indicating that their value cannot be modified once assigned. Here’s an example:

 #include <stdio.h>

 int main() {
   const int MAX_VALUE = 100;
   printf("Max value: %d\n", MAX_VALUE);;
 }

Start developing this habit to mention the constant values during programming which make you code to be more understandable. After using const for variable MAX_VALUE, I cannot change the value for this variable. You can try to do it and you will see errors like:

 expression must be a modifiable lvalue
 assignment of read-only variable ‘MAX_VALUE’