Constants in C programming Language

Let’s have a glance at the Constants in C programming language.

What Are Constants in C Programming Language?

Constants are referred to as fixed values that the program may not change during its execution.
These fixed values are also called literals. Constants can be of any of the basic data types like an integer constant, a floating constant, a character constant, or a string literal. There are enumeration constants as well.
Constants are nothing just a fixed value that is fixed during the execution of the program.

Important things regarding Constants:

  • The value of Constant cannot be altered or modified.
  • It can be treated as a variable.
  • It can be of any basic data types in the C programming language.

Declaration of Constants

There are 2 ways to define constants in C Programming

Using #define preprocessor directives.
The syntax of declaring constant using #define preprocessor directives.

#define Constant_Identifier Value

Using const keyword in the variable declaration.
The syntax of declaring constant using the const keyword.

const data_type variable_name = Constant;