Breaking News
You are here: Home / Notes / SEM-2 / C / Using Constants in C

Using Constants in C

Using Constants in C

constants in c

constants in c


Constants in C

  • Like a variable, a constant is a data storage location used by your program.
  • Unlike a variable, the value stored in a constant can’t be changed during program execution.
  • It is a fix value which can not be change during the program execution.
  • There are four types of constant

1.       Integer Constant

    • It contains only Digits 0 to 9
    • Eg. 23

2.       Floating Pont Constant

    • It contains only Digits 0 to 9 and Decimal point
    • Eg. 20.12

3.       Character Constant

    • It contains only Single Character
    • Eg. ‘A’

4.       String Constant

    • It contains Sequence of one or more Characters terminated by a NULL Characters
    • Eg. “Hello India”


Defining Constants

There are two method s to Define a Constant


1.        Using const Keyword

2.        Using #define directive

[1] Using const Keyword

const int count = 100;
const float pi = 3.14159;


  • You can declare the const before or after the type. Choose one an stick to it.
  • It is usual to initialise a const with a value as it cannot get a value any other way.


[2] Using #define directive

#define PI 3.14159

Download Paper Solutions from Below Link

About admin

Scroll To Top