C Const - Const in C Programming
![const in c programming](https://wikitechy.com/cdn/tutorials/c-programming/const-in-c-programming.gif)
Learn C - C tutorial - const in c programming - C examples - C programs
Const in C Programming
- Const is an identifier that identify a constant value.
- The word const is a keyword in c language that makes identifier constant.
- We can change the value of it’s at run time.
Sample code
#include <stdio.h>
int main()
{
const int value2=20;
printf("Value of value2: %d\n",value2);
value2=30;
printf("Value of value2: %d\n",value2);
return 0;
}
Output
main.c:6:7: error: assignment of read-only variable ‘value2’
value2=30;