Constant in C++

  •  Constants are also like normal variables. But, only difference is, their values can not be modified by the program once they are defined.
  • Constants refer to fixed values. They are also called as literals
  • Constants may be belonging to any of the data type.
  • Or
  • Constants are values that are hard-coded into a program, and which do not chnage value. E.g. "3.14159".
  •  
  1. Integer constants
  1. Real or Floating point constants
  1. Octal & Hexadecimal constants
  1. Character constants
  1. String constants
  1. Backslash character constants
S.no
Constant type
data type
Example
1
Integer constants
int
unsigned int
long int
long long int
53, 762, -478 etc
5000u, 1000U etc
483,647
2,147,483,680
2
Real or Floating point constants
float
doule
10.456789
600.123456789
3
Octal constant
int
013          /* starts with 0  */
4
Hexadecimal constant
int
0×90        /* starts with 0x */
5
character constants
 char
‘A’   ,   ‘B’,     ‘C’
6
string constants
char
“ABCD”   ,   “Hai”


Comments

Popular posts from this blog

Umbrella activities in Software Engineering

Operating System | Best Definition of Opetating System