Constants:
Constants refer to fixed values that do not change during the execution of a program.
TYPES OF C CONSTANT:
1. Integer constants
2. Real or Floating point constants
3. Character constants
4. String constants
5. Backslash character constants
Integer constants: An integer constant is a numeric constant (associated with number) without any fractional or exponential part. There are three types of integer constants in C programming:
decimal constant(base 10) octal constant(base 8) hexadecimal constant(base 16)
For example: Decimal constants: 0, -9, 22 etc Octal constants: 021, 077, 033 etc Hexadecimal constants: 0x7f, 0x2a, 0x521 etc
1: Decimal Integer : the rules for represent decimal integer. a) Decimal Integer value which consist of digits from 0-9. b) Decimal Integer value with base 10. c) Decimal Integer should not prefix with 0. d) It allows only sign (+,-). e) No special character allowed in this integer.
2 : Octal : An integer constants with base 8 is called octal. These rules are : a) it consist of digits from 0 to 7. b) It should prefix with 0. c) It allows sign (+,-). d) No special character is allowed.
3 : Hexadecimal : An integer constant with base value 16 is called Hexadecimal. a) It consist of digits from 0-9,a-f(capital letters & small leters. Ex : 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 b) it should prefix with 0X or 0x. c) it allows sign (+,-). d) No special character is allowed.
Floating point/Real constants:
A floating point constant is a numeric constant that has either a fractional form or an exponent form. For example
.34
2.56
Real Constants : Real constant is base 10 number, which is represented in decimal 0r scientific/exponential notation.
Real Notation : The real notation is represented by an integer followed by a decimal point and the fractional(decimal) part. It is possible to omit digits before or after the decimal point.
String constant : A string constant is a sequence of characters enclosed in double quote, the characters may be letters, numbers, special characters and blank space etc EX : “rama” , “a” , “+123” , “1-/a”