Constants in C programming Language

In this programming language tutorial, we are going to have a look at Constants In C Programming Language and few important aspects of Constants.

WHAT ARE CONSTANTS IN C PROGRAMMING LANGUAGE?

Constants are nothing just a fixed value that is fixed during the execution of the program.
Important things regarding Constants n C programming

  1. Value of Constant cannot be altered or modified.
  2. It can be treated as a variable.
  3. It can be of any basic data types in the C programming language.

DECLARATION OF CONSTANTS IN C

There are 2 ways to define constants in C Programming

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

 #define Constant_Identifier Value

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

const data_type variable_name = Constant;

Leave a Reply

Shopping cart