constant

constant is an modifier of data type in c

Syntax

const data_type var_name;

Declearation of constant variable

const int data;

Properties of constant variable

  • we can only assign the value to the constent variable at the time of declaration.
  • after declaration, we can't assign/modify the value to the constant variable
  • the exeucution time of constant variable is faster as compare to another variable.

Rules:

constant modifier can not be used with void, enum and function.


Advanced reader:

We can modify the value of constant variable using pointer.


©2023-2024 rculock.com