HOME LIBRARY C++ PHP JAVA HTML
CSAdeeb

Declaring Variable as Constant in C

ANSI C supports data type qualifier const to declare a variable as constant in a C program. We have already learned that constants in C language have fixed values that do not change during the program.

If we declare a variable as a constant, the value of that variable remains constant during the execution of the program.

We use the keyword const to declare a variable as a constant. For example,

const int pass_mark = 45;

The above code tells the compiler that the value of the variable should not be changed during the program execution.