Constants in C language | what is Constant and Different types of Constants

Spread the love

Constants :

Constant is value that cannot be changed during execution of program. in other words It is Fixed one never be changed during the program execution. 
Constants are classified into three types those are,.

  1. Numeric Constants.
  2. Character Constants.
  3. String Constants.

Numeric Constants :

Numeric Constants are contains Numbers they may have fractional part or may not have fractional part(Decimal Part).
C have few rules to construct Numeric constants those are
  • Numeric constant should have at-least one digit.
  • No comma are Space is allowed within the Numeric Constant.
  • Numeric Constants are positive or Negative if you don’t specify any sign default sign is Positive.
Again Numeric constants are further classified into two types
  • Integer Constants.
  • Decimal Constants. 
Integer constants are all Numbers which doesn’t contains Decimal Point (.).
Ex : 431, 85, 65, 31….etc.
Real Constants are Numeric constants that contains Decimal Point.
Real Constants also called as Floating point Constants. The real constants can be written in two forms, Fractional form and Exponential form.
Ex : 0.7, 4.31, 98.2,…etc.    ( Fractional representation ).
Ex : +4.3e-5, 1.2e+5,…etc. ( Exponential Representation ).

Character Constants :

A Character Constant is single character it is enclosed by the single quotes ( ‘ ‘ ).
some Valid character constants are ‘M’    ‘V’     ‘4’     ‘$’   ‘’   …etc.
Some Invalid character constants are ..,
‘Venkatesh’              There should be only one character within the single quotes.
“M”                          Double quotes are not allowed, Character constant must be within single quotes.
    v                            Single quotes are missing.

String Constants :

A string character has zero or one or more characters, A string character must be Enclosed within the Double Quotes.(” “).at the end of the string constant compiler automatically adds one NULL(‘’) character.
There is no separate Datatype for string constants c uses Character array to describe String data.

Character constants are enclosed by single quotes and string constants are enclosed by Double quotes. “V” and ‘v’ are completely different first one is string constant and second one is character constant and first one contains two characters one is V and another character is Compiler placed NULL Character while second one is contains only one character i.e v.

These are the available constants in C language.


Hi Guys, I am Venkatesh. I am a programmer and an Open Source enthusiast. I write about programming and technology on this blog.

You may also like...

Leave a Reply