C Variables & constant
Variables are identifiers.
They are the names given to memory location that are used to store values.
Each memory location has a unique address.
They can store the values of a type they are declared by using suitable data type.
int i = 5;
Here i is a variable of type int.
Therefore it can store values/constants of integer type only.
Number 5 is an integer constant.
Integer constant (value) 5 is stored at certain memory location whose name is i and of type int.
The value that cannot be altered is known as a constant.
Type of constants
Numbers without fraction are called integer constants.
Following are the types of integer constants:
i) Decimal constant (with base 10)
It uses digits – 0,1,2,3,4,5,6,7,8,9.
Few examples of Decimal constant
0, 1, 10, 30, 1002, etc.
ii) Octal constants (with base 8)
It uses digits – 0,1,2,3,4,5,6,7.
Few examples of Octal constant
07, 033, 0321, etc.
iii) Hexadecimal constants (with base 16)
It uses 16 distinct symbols – 0 to 9 & A,B,C,D,E,F (Uppercase/Lowercase).
Few examples of Hexadecimal constant
0X84, 0XA, 0X6DB3, etc.
Numbers with fraction are called real constants.
0.1, 5.3, -63.9, 999.9, 9.5e-3, 6.3e2, etc.
A character between single quotes is known as a character constant.
‘A’, ‘X’, ‘P’, ‘ ’, ‘$’, etc.
A constant between double quote is known as a string constant.
“C programming”, “ ”, “A”, etc.