CONSTANT
In a program, a name May be assigned to a data item. If it remains the same, throughout the program execution, then we say that the value of name is a constant. Thus, constant (literals) is a value, written into a program instruction that does not change during the execution of a program. There are three types of constants as below:
- String constant
- Numeric constant
- Character constant
String Constant
A string constant or literal is a sequence of alphanumeric characters enclosed in double quotation marks the maximum length of a string constant is limited to 255 characters. Each string constant is automatically added with a terminating character ‘\0’.Thus the string “abc” will actually be represented as “abc\0” in the memory and its size is 4 characters.
Numeric Constant
Numeric constant has a constant value in number. The value of the constant can be positive or negative. There are 4 types of numeric constants as follows.
- Integer Constant: – Integer constants are whole numbers. An integer constant may be either a short integer or long integer.
- Floating Point Constant: – A floating point constant has a real value. It may be written in two forms called the fraction form such as 0.3 and the other as exponent form such as 3.7e12.
- Octal Constant: – Octal numbers are the integer numbers with a base 8. The digits allowed in this system are 0 to 7.
- Hex Constant: – Hex decimal numbers are integer numbers to the base 16. The digits allowed in this system are 0 to 9 and letters A to F.
Character Constant
Character constant is either a single alphabet or a single digit or a single special symbol enclosed within a pair of single quotation mark, such as ‘A’, ‘a’, ‘.’, ‘?’.
IDENTIFIERS
IDENTIFIERS
Identifiers are refers to the names of variables, functions and arrays. Identifiers are also the names of objects, which can take different values but only one value at a time. Once a value is assigned to an identifier, it cannot be changed during the execution of the program.
