Constants In C Language

Constants In C Language

A constant is an identifier that refers to the fixed values that do not change during the execution of a program.

Declaring constants :
We can declare constant variable using constkeyword.

Example (syntax) :

type const variable_name = value; 
constant float const pi = 3.14;
int const a = 5;
Symbolic Constants :
Symbolic Constant is a name that substitutes for a sequence of a characters or a numeric constant, a character constant or a string constant.

Syntax :

#define name text;
* Name implies symbolic name in a caps
* Text implies value or the text.

Example :

#define printf print
#define MAX 100
The # character is used for preprocessor commands. A preprocessor is a system program, which comes into action prior to the compiler and it replaces the replacement text by the actual text.
That’s all with the constants in c language. Let’s see more with c language in the coming posts.

One Reply to “Constants In C Language”

Leave a Reply

Your email address will not be published. Required fields are marked *