// Write a Program to Print Constant and Variable with Different Ways
//to show the Constant value never change.
#include <stdio.h>
#include <conio.h>
void main()
{
int var;
const int con=20;
var=10;
printf("The Value of the Variable Before updation is = %d\n",var);
printf("The Value of the Constant Before updation is = %d\n",con);
// Try to Update the Value Again
var=20;
con=30;
// we can not update the constant value other wise give the error
printf("The Value of the Variable after updation is = %d\n",var);
printf("The Value of the Constant after updation is = %d\n",con);
}
Output
//In the above program we can not update the constant value now try to update in the variable value only.
#include <stdio.h>
#include <conio.h>
void main()
{
int var;
const int con=20;
var=10;
printf("The Value of the Variable Before updation is = %d\n",var);
printf("The Value of the Constant Before updation is = %d\n",con);
// Try to Update the Value Again
var=20;
// we can update the Variable value.
printf("The Value of the Variable after updation is = %d\n",var);
printf("The Value of the Constant after updation is = %d\n",con);
}
Output
The Value of the Variable Before updation is = 10
The Value of the Constant Before updation is = 20
The Value of the Variable after updation is = 20
The Value of the Constant after updation is = 20