What is an Operator:-

The operators are a special symbol that is used for mathematical or logical operations on numbers or operands in C++.

Operator in c++

There are many types of Operators in C++.

  1. Arithmetic Operator
  2. Relational Operator
  3. Logical Operator
  4. Assignment Operator
  5. Increment and Decrement Operator
  6. ternary Operator
  7. Bitwise Operator

1) Arithmetic Operator

C++ provides all the basic arithmetic operators, they are +, -, *, /, %. The modulo division (%) produces the remainder of an integer division.

a + baddition
a – bsubtraction
a * bmultiplication
a / bdivision
a % bmodulo division
Arithmetic Operator

Relational Operator

These are the operators used to Compare arithmetic, logical and character expressions. The value of a relational expression is either one or zero . It is 1 if one is the specified relation is true and zero if it is false .

<is less than
<=is less than or equal to
>is greater than
>=is greater than or equal to
==is equal to
!=is not equal to
Relational Operator

Logical Operator

Logical Operators are used when we want to test more than one condition and make decisions. here the operands can be constants, variables and expressions

&&Logical AND
| |Logical OR
!Logical NOT
Logical Operator

Assignment Operator

Used to assign the result of an expression to a variable. ‘= ‘is the assignment operator.

=Assign value
Assignment Operator

Increment and Decrement Operator

The Operator + + adds 1 to the operand while — subtracts 1, Both are unary operators. Increment and decrement operators are unary operators and they require variable as their operands.

They take following forms:

++m or m ++

--m or m—

++m is equivalent to m=m+1; (or m+=1 ;)

--m is equivalent to m=m-1; (or m-=1 ;)

Consider following :



here in this case the value of y and m would be 6. And suppose m=5;


then here the value of y would be 5 and m would be 6.

A prefix operator first adds 1 to the operand and then the result is assigned to the variable on left.

A postfix operator first assigns the value to the variable on the left and then increments the operand.

– –Decrement
Increment and Decrement Operator

ternary Operator

ternary operator is used to check a condition and Select a Value depending on the Value of the condition. It is also known as conditional operator. And it is “? :”

a < b ? true_block : false_block;

Bitwise Operator

Bitwise operators are used to perform operations at binary level i. e. bitwise. These operators are used for testing the bits, or Shifting them right or left . ” These operators are not applicable to float or double. “.

&Bitwise AND
|Bitwise OR
^Bitwise Exclusive – OR
<<Left shift
>>Right shift
~Complement (bitwise not)
Bitwise Operator