Constants in C – types of Constants in C

Constants in C programming types of Constants in C

What are Constants in C programming

Constants is a such data type, value of constants fixed and do not change throughout the program, If programmer use constants data type in any c program and the value of constant will not change during program execution, programmer specify the values of constants in a c program and compiler know the these constants value you can not change the value constant during program run time.

Types of Constants in C programing

There are basic two type of constants in c programing, Numeric Constants and Character Constants.

Numeric Constants : 

Numeric constants further divided in two type Integer and Floating Real Constants

Integer Constants are sequence of digits and have type of Decimal, Octal and Hexadecimal.

Rules for Integer constants

 234 is valid Constants

26,100 is not valid Constants comma not allowed

$123 in not valid Constants special character not allowed

27  200 this not valid constants space is not allowed

36  ,  4857   is valid constants

               Floating Real Constants having fractional part and these can be in exponential form.

15.12 is valid constants

12.10.25 in not valid constants

    Character Constants

Character Constants further divided in Single Character Constants and String Constants

Single Character Constants are enclosed in single quotation mark

example :  ‘a’   ‘b’    ‘c’   ‘@’      ‘,’

‘a’ = 25

‘A’ = 45

‘5’  is also single character constant

5  in not equal to ‘5’ because  ‘5’ is a character constants and 5 is a numeric constant

 

and ‘/0’ this is backslash zero constant having different in c programming language

there are single Character constant in c

 

Leave a comment