DATA TYPE SIZE (IN BYTES) RANGE
short int 2 -32,768 to 32,767
unsigned short int 2 0 to 65,535
unsigned int 4 0 to 4,294,967,295
int 4 -2,147,483,648 to 2,147,483,647
long int 4 -2,147,483,648 to 2,147,483,647
unsigned long int 4 0 to 4,294,967,295
long long int 8 -(2^63) to (2^63)-1
unsigned long long int 8 0 to 18,446,744,073,709,551,615
signed char 1 -128 to 127
unsigned char 1 0 to 255
float 4 1.8E-38 3.4E+38
double 8 2.2E-308 1.8E+308
long double 12 2.2E-308 1.8E+308
wchar_t 2 or 4 0 to 65,535
Operator in any computer language works like a command or statement to tell the computer that what kind of action is required to be
performed. The data on which action is performed by the operators is called operands. Some operators work on single operand and
are called unary operators. Most of the operators need two operands to work on and are called binary operators. There is only one
ternary operator in C++ which needs three operands.
Arithmetic Operators
All the arithmetic operators are binary operators having two operands. They arithmetically calculate a value and return the result.
perators Description Examples
a+b
if a=15 and b=2 then the result of above expression is 17
Used to arithmetically calculate sum of two
+ values.
a-b
if a=15 and b=2 then the result of above expression is 13
Used to arithmetically calculate difference of
– two values.
a*b
if a=15 and b=2 then the result of above expression is 30
Used to arithmetically calculate product of two
* values.
a/b
if a=15.0 and b=2.0 then the result of above expression is
7.5
Used to arithmetically divide one value by
/ another and produces the quotient
a%b
Used to arithmetically divide one value by
another and produces the remainder. It is also if a=15 and b=2 then the result of above expression is 1
called modulus operator and must have whole
% numbers as operands.
Relational Operators
All the relational operators are binary operators having two operands. They compare the numeric value at the left hand side with the
value at the right hand side and return true or false. In C++, 0 is represented as false and any non-zero value is considered as true
but usually 1 is used as true.
Operators Description Examples
Checks whether the value at left hand side is
less than or not from the value at the right hand
< side. a<b
Less than if a=15 and b=2 then the result of above expression is 0
(false)
if a=2 and b=2 then the result of above expression is 0
(false)
if a=15 and b=22 then the result of above expression is 1
(true)
a>b
if a=15 and b=2 then the result of above expression is 1
(true)
if a=2 and b=2 then the result of above expression is 0
(false)
>
if a=15 and b=22 then the result of above expression is 0
Greater than Checks whether the value at left hand side is (false)
greater than or not from the value at the right
hand side.
a<=b
if a=15 and b=2 then the result of above expression is 0
(false)
if a=2 and b=2 then the result of above expression is 1
<= (true)
Less than or equal if a=15 and b=22 then the result of above expression is 1
to Checks whether the value at left hand side is (true)
less than or equal to the value at the right hand
side or not.
a>=b
>=
if a=15 and b=2 then the result of above expression is 1
(true)
Greater than or
equal to Checks whether the value at left hand side is
greater than or equal to the value at the right
hand side or not. if a=2 and b=2 then the result of above expression is 1
(true)
if a=15 and b=22 then the result of above expression is 0
(false)
a==b
==
if a=2 and b=2 then the result of above expression is 1
Equal to (true) otherwise 0 (false)
Checks whether the value at left hand side is
equal to the value at right hand side or not.
a!=b
!=
if a=2 and b=2 then the result of above expression is 0
Not equal to (false) otherwise 1 (true)
Checks whether the value at left hand side is
equal to the value at right hand side or not.