Const variable:
-const variable are those variable whose value is not changed during the entire execution of program.
-only read only is valid on constant variable.
-If you try to change the value of const variable during run time then it will give an error.
program:
#include < iostream>
using namespace std;
int main()
{
const int i=10;
cout<< i;
return 0;
}
10
#include < iostream>
using namespace std;
int main()
{
const int i=10;
cout<< i;
i++;
return 0;
}
Error: increament of read-only variable 'i'