Tuesday, 18 December 2018

Constants

Numeric Constant :
These have numeric value with a combination of sequence of digits i.e. from 0 to 9 as alone or combination of digits with or without decimal point having a positive or negative sign. These are further classified into two types:
1. Integer Constant
 2. Real Constant

1. Integer Constant :
Integer numeric constants have integer data combination of 0to 9 without any decimal point or without precision with positive or negative sign. These are classified into three types.

 They are : 1. Decimal Integer Constant
2. Octal Integer Constant
3. Hexadecimal Integer Constant Decimal Integer Constant:
* Integer constants have integer data combination of digits 0 to 9.
* It may have an optional sign, in case of absence considered as +.
* Commas, blank spaces and period should not be a part of it. Ex :12, 3, -21 etc… Octal Integer constant:
* It is a sequence of digits i.e. 0 . . . . 7.
* It may have an optional sign, in case of absence considered as +.
* Commas, blank spaces and period should not be a part of it.
* It should start with a “ 0 “(zero). Ex : 012,-0213. Hexadecimal Integer Constant:
* It is a sequence of digits i.e. (0 . . . . 9) (A . . Z) (a . . z).
* It may have an optional sign, incase of absence considered as +.
* Commas, blank spaces and period should not be a part of it.
* It should start with a “ OX or Ox “. Ex : OX3b, Ox2.

2. Real Constant : Constants having a decimal point or precision value within it having any positive or negative sign is called Real numeric Constant. It is also called floating point constant.Real numeric constants are further classified into two types. They are:
 1. Fractional form
 2. Exponential form Fractional form :
* Must have a decimal point.
* It may have an optional sign, incase of absence considered as +.
* Commas and blank spaces should not be a part of it. Ex : 3.12,2.3 Exponential form :
This offers a convenient way for writing large and small real constants. Ex: 3e4, 0.12e3
Character Constant : Character constants have either a single character or group of characters or a character with back slash used for special purpose. These are categorized into three types including the back slash character constant.
They are:
1. Single Character Constant
2. String Character Constant
3. Backslash Character Constant
1. Single Character Constant : Any character enclosed within a single quote (‘ ‘) is a Single character constant. A single character constant may be a single letter, single digit, or a special character placed within quotes. The maximum length of single character constant is 1. Ex : valid invalid ‘n’ ‘nitya’ ‘3’ ‘321’ 2. String Character Constant : A string is the combination of characters or group of characters. A string character constant or a string is enclosed within double quotes (“ “). The maximum length of string character constant is 255 characters. Ex : valid invalid “nitya” “nitya “hai welcome” hai welcome “ “welcome to 2013” 3. Backslash Character Constant : These are used in output statements like printf(), puts() etc. The different types of backslash characters are :


No comments:

Post a Comment