Constants in C++
Using Constants in C++?
are values that will not change when a program is executed. These are also known as "literals" and it can be of any data type and they are usually declared using the keyword "const". Types of constants are integer, character, hexadecimal, octal, string constants, backslash character constants.
int main( )
const long int l = 35000L-34L;
\ Integer Constant
const int hex = 0x80;
\ Hexadecimal Constant
cout << "Integer constants value is:" << l << '\n';
cout << "Hexadecimalconstants value is:" << hex << '\n';
printf ("\n\t This is hscripts"); \ String Constant
Integer constants value is: 34966
Hexadecimal constants value is: 128
This is Hscripts.
In the above example a long integer, a hexadecimal equivalent of 128 are declared as constants.