## Constant in C

Constant :-

A constant is a fix quantity which does not change with the execution of program and remain same throughout the program . These constants can be Numeric or character or string constant . eg. 1 , 1.5 , 'A' , "English" etc.

If we try to divide constants , we can divide constants into Four parts . Now lets Disscus Them in detial

1). Integer Constants :-

An integer constant is an integer number which is a combination of digits from 0 to 9 . If the constant contain two or more digits , the first digit must be something other from zero(0) .

Following are the rules for constructing Integer constant .

An integer constant must contain at least one digit .

It must not have any decimal point .

Integer constant can be positive or negative . If No sign is present , it assume Positive sign as default .

No commas or blank-spaces or signs are allowed in an integer constant .

eg.             0           1           +8           +9           -14           99           1991

2). Floating Point constants :-

The Floating point constant is a number which is also a combination of digits from 0 to 9 BUT it must contain a Decimal point .

Following are the rules for constructing Floating Point constant .

It must contain at least one digit and only one point .

If there is No decimal point it is assumed after the last(right-most) digit .

Integer constant can be positive or negative . If No sign is present , it assume Positive sign as default .

No commas or blank-spaces or signs other from decimal(point) are allowed in an integer constant .

eg.     0.00           1.00         1.5         +8.0000         +8.5         -14.0000           -14.0         -14.5

3). Character constants :-

A Character constant is a character enclosed in single quotes ( apostrophes ) . It can be Alphabets , Digits , or any special symbol . It need a fix memory space (1 byte to store one character ) The character constant have numeric values listed in ASCII Table .

eg. 'A'         ,           'a'   .

( These two are not same , because character 'A' has numeric value 65 and character 'a' has numeric value 97 according to ASCII Table . )

Following are the rules for constructing Character constant .

It can contain any alphabet(Upper/Lower) , Numeric(0,1,2,3,4,5,6,7,8,9) , or special symbol .

We should remember that if we use any symbol like   +   it is ADD operator

BUT if we write     '+'   this is character constant with value 43   .

4). String constants :-

A string constant is a collection of character constants (character array) enclosed in Double quotes.

eg. "India"     ,     "HSK 4061"     ,       "HSK_4061"     ETC.

Following are the rules for constructing string constant .

The string constant must be written in Double Quotes ("_____").

You must know that a Null character( | 0 ) is inserted after the last character ( automatically from the compiler ) .

### Who's online

We have 8 guests and no members online Hello

This website is a special gift for Programming Lovers , which want to learn basic Programming Languages and want to develop there skills Read More....

### Find Us

This email address is being protected from spambots. You need JavaScript enabled to view it.