## What is an Operator:-

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

**There are many types of Operators in C++.**

- Arithmetic Operator
- Relational Operator
- Logical Operator
- Assignment Operator
- Increment and Decrement Operator
- ternary Operator
- Bitwise Operator

## 1) Arithmetic Operator

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

Operator | Meaning |
---|---|

a + b | addition |

a – b | subtraction |

a * b | multiplication |

a / b | division |

a % b | modulo 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 .

Operator | Meaning |
---|---|

< | 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**

**Also Read This :- application of c++**

## 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

Operator | Meaning |
---|---|

&& | Logical AND |

| | | Logical OR |

! | Logical NOT |

## Assignment Operator

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

Operator | Meaning |
---|---|

= | 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 :**

m=5;

y=++m;

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

y=m++;

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.

Operator | Meaning |
---|---|

++ | Increment |

– – | 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. “.

Operator | Meaning |
---|---|

& | Bitwise AND |

| | Bitwise OR |

^ | Bitwise Exclusive – OR |

<< | Left shift |

>> | Right shift |

~ | Complement (bitwise not) |

**Bitwise Operator**