Constant is computer programming

In computer programming, a constant is an identifier .A constant has an associated value . This value cannot be altered or changed during normal execution of program or application .This is why , it is called constants.


constant example

To understand it read the following example . Suppose you are going to write a program in any language such as C language.  And define two variables .

Variable numberOne and variable numberTwo . numberOne is an integer and numberTwo is a constant . Values of variable are as follows .

int numberOne = 1 ;

const int numbeTwo = 2;

In this example numberOne value is 1 and numberTwo value is 2 .

Sample code of c Language

#define MAX 10

void main()


int numberOne = 1 ;

const int numbeTwo = 2;

numberOne = 3;

numberTwo = 4;



In this sample C language code we try to change value of variables during execution . We try to change numberOne value to 3 and numberTwo value to 4 .

But when we try to execute this code using printf statement , this code not works properly and give error . As result of this code ,numberOne value is change because it is a integer . But numberTwo value cannot be changed due to it is a constant .