![]() |
| What is Constants in C language ? |
Upon completing this article,you will be able to:
- What is Constant in C language ?
- Different types of Constant in C language.
- What is Numeric Constant in C language ?
- What is Character Constant in C language ?
- What is Integer Constants in C language ?
- What is Real Constant in C language ?
- What is Single Character Constant in C language ?
- What is String Constant in C language ?
Constants in C:-
Constants in C language refer to fixed values that do not change during the execution of a program.C support different types of constants as illustrated in fig
Numeric Constant in C:-
There are two types of Numeric Constant are define in C language.
- Integer Constant.
- Real Constant.
1.Integer Constant in C:-
An integer constant in C language is nothing but it is a sequence of digits.There are three types of integers constant namely,decimal integer,octal integer and hexadecimal integer.
- Decimal integer constant consist of a set of digits,0 through 9,preceded by an optional - to +.Valid example of decimal integer are:123, -321,0,+76 etc.
- An octal integer constant consists of any combination of digits from the set 0 through 7,with a leading 0.Some example of octal number are: 034,0,0455,0551 etc.
- A sequence of digits preceded by 0x or 0X is considered as hexadecimal integer constant.They may also include alphabet A through F, The letter A through F represent the numbers 10 through 15.Following are the example of valid hex integers are: 0X2,0x9F,OXBCD etc.
2.Real Constant in C:-
Integer number are inadequate to represent quantities that vary continuously,such as distance,heights,temperature,prices and so on.These quantities are represented by numbers containing fractional part like 17.548.Such number are called real or real constant.
- These constant are shown in decimal notation,having a whole number followed by a decimal point and the fractional part.It is possible to omit digits before the decimal point or digit after the decimal point.i.e: 215.,.87,-.71 are all valid number.
- A real number may also be represent in exponential(scientific notation).For example the value 215.65 may be written as 2.156e2 in exponential notation,e2 multiply by 100.
Character Constant in C:-
- Single Character Constant.
- String Constant.
1.Single Character Constant in C:-
- The ASCII value of uppercase letter(A to Z) is from 65 to 90.
- The ASCII value of lowercase letter(a to z) is from 97 to 122.
- The ASCII value of 0 to 9 is from 48 to 57.
- The ASCII value of special character(&,%) is from 33 to 47.
C support some special type of constant which is Backslash Character Constant,This constant is used in output functions.For example,the symbol '\n' stand for newline character.

