OPERATORS IN C++ http://www.tuto rialspo int.co m/cplusplus/cpp_o pe rato rs.htm
Co pyrig ht Š tuto rials po int.co m
An operator is a symbol that tells the compiler to perform specific mathematical or log ical manipulations. C++ is rich in built-in operators and provides the following types of operators: Arithmetic Operators Relational Operators Log ical Operators Bitwise Operators Assig nment Operators Misc Operators T his chapter will examine the arithmetic, relational, log ical, bitwise, assig nment and other operators one by one.
Arithmetic Operators: T here are following arithmetic operators supported by C++ lang uag e: Assume variable A holds 10 and variable B holds 20, then: Show Examples
O perator
Desc ription
Example
+
Adds two operands
A + B will g ive 30
-
Subtracts second operand from the first
A - B will g ive -10
*
Multiplies both operands
A * B will g ive 200
/
Divides numerator by de-numerator
B / A will g ive 2
%
Modulus Operator and remainder of after an integ er division
B % A will g ive 0
++
Increment operator, increases integ er value by one
A++ will g ive 11
--
Decrement operator, decreases integ er value by one
A-- will g ive 9
Relational Operators: T here are following relational operators supported by C++ lang uag e Assume variable A holds 10 and variable B holds 20, then: Show Examples
O perator
Desc ription
Example
==
Checks if the values of two operands are equal or not, if yes then condition becomes true.
(A == B) is not true.