Integer Constant Essay

850 Words2 Pages

Integer Constant An integer constant is made up of digits without decimal point. Rules  The integer constant is formed with digits 0 to 9  Commas and blank spaces are not allowed.  The constant can be preceded by + or – sign  No special characters are allowed.  The value of constant cannot exceed the specified minimum and maximum bounds. There are three types of Integer constants. They are i) Decimal Constant ii) Octal Constant iii) Hexa Decimal Constant Decimal Constant A decimal integer constant is made up of digits 0 to 9 in any combination. The first digit should not be zero. Example for valid decimal integer constants i) 10 ii) 20 iii) 30 The following are invalid decimal integer constants 17,300 - Comma is not allowed 0732 - The …show more content…

Octal Constant An octal integer is made up of digits 0 to 7 in any combination. To identify the constant as an octal constant it should begin with zero (0). Example for valid octal integer constants: i) 07 ii) 0176 iii) -0742 iv) 0100 The following are invalid octal integer constants 5743 - The first digit should be zero 01728 - The digit 8 is not allowed 01781 - The blank space is not allowed 071.82 - The decimal point is not allowed. Hexadecimal integer constant A hexadecimal integer constant is made up of digits 0 to 9 and alphabets A to F in any combination. To identify the constant as a hexadecimal constant, it should begin with either ox or OX. Example for valid hexadecimal constants: i) Ox1F ii) OX7139 iii) oxff The following are invalid hexadecimal constants: i) 23A - It should begin with ox ii) Ox741.76A - The decimal point is not allowed iii) OxABZ - The character ‘Z’ is not allowed. Real or Floating point constant Any number written with one decimal point is called real constant or floating point constant. Rules:  The real constant is formed with the digits 0 to 9 and a decimal …show more content…

 Exponent should not have a decimal point.  The letter e separating the mantissa and exponent can be written in either lower case or uppercase. Example for valid exponent form real constant: i) 0.65e4 ii) 1.2e-2 iii) 1.5e+5 iv) 3.18e3 v) -1.5E-1 vi) 0.000002571 can be expressed as .2571E-5 The following are some invalid exponent real constant: i) 0.840E0.5 - Exponent should not have decimal point. ii) 80.40E17 - Either +or –sign should not used. iii) 50 - Omission of exponent part in the constant. Character Constant There are two types of character constants. They are i) Direct Constant ii) Escape Sequence Direct Character Constant A direct constant contains a single character enclosed within a pair of single quotation marks. This gives the integer value of the enclosed character which is known as ASCII value. Example: Constant Value ‘A’ ‘B’ ‘%’ ‘a’ 65 66 37 97 Escape Sequence An escape sequence consists of more than one character enclosed within single quotes. The first character must be a backslash. Though it has more than one character, it represents only one. CONSTANT MEANING ‘\a’

More about Integer Constant Essay

Open Document