• Have Any Question?
  • contact@eitworld.com

C Constants

  • Constant in C language are also the name given to the data values stored in memory like variable but the value of constant cannot be changed at the time of execution.
  • There are several types of Constants in C. They are classified in the two groups as given below in the figure:


Numeric Constants


Numeric constants can be of two types Integer and real constants:

Integer Constants
  • Integer constant are sequence of number from digits 0 to 9 without any decimal point or fractional parts.
  • Integer constants can be positive or negative.
  • The number without any sign assumed to be positive number.
  • Integer constants can be of minimum 2 bytes and maximum 4 bytes.
  • Here are some examples of Integer constants:
45, -16, +56, 67 etc.
Real Constants
  • Real constant are also known as floating point constants which contains decimal point as well as fractional parts.
  • Real constants can be positive or negative.
  • The number without any sign assumed to be positive number.
  • Real constants can be written in exponential notation which contains two parts mantissa and exponent.
  • The mantissa and exponent part are separated by a letter e.
  • Mantissa is a real number represented in decimal or integer it can be positive or negative. Whereas exponent is an integer number that can be positive or negative.
  • Here are some examples of real constants:
+2.7, -3.8, 6.7, 4.5 etc



3.4e-7 etc.

Character Constants


Character constants can be categorized into two parts:

Single Character Constants
  • A single character constant can be a alphabet, digit or special symbol enclosed in single quote.
  • Single character requires only one byte.
  • Here are some examples of single character constants:
‘A’, ‘b’, ‘@’, ‘8’ etc.
String Constants
  • String constants in c are sequence of characters enclosed in double quotes.
  • Here are some examples of string constants:
“Ram”, “Good”,”1234″, “@@@@”

Declaration of Constants

    • You have to declare the constant before using it into the program.
    • Constant is declared using the keyword ‘const’.
    • Here is the syntax for declaring constant in C.
const data-type constant_name=data_value;
    • Some examples of declaring constant in C++ are given here:
const int a=10;

const float b=10.34;

const char c=’a’;

    • Here is an example of using constant in C program:


int main()


const int a=10;/*constant declaration*/

printf("nvalue of a is:%d",a);

return 0;


  • The output of the above program is as follows:
value of a is:10

Real Time Web Analytics