const
The const keyword defines a variable who’s value cannot be changed.
const int num = 10;
Below is the C program to demonstrate the const keyword:
// C program to demonstrate
// const keyword
#include <stdio.h>
// Driver code
int main() {
const int a = 11;
a = a + 2;
printf("%d", a);
return 0;
}
This code will produce an error because the integer a was defined as a constant and it’s value was later on changed.
Output:
error: assignment of read-only variable 'a'
a = a + 2;
Keywords in C
In C Programming language, there are many rules so to avoid different types of errors. One of such rule is not able to declare variable names with auto, long, etc. This is all because these are keywords. Let us check all keywords in C language.