# C++ Operators

C++ operators are symbols that are used in the C++ program to form an expression.C++ has a large set of operators. It includes all C languages operator and has its own other operators. There are three categories of an operator in C++. They are listed below:

1. Unary Operators
2. Binary Operators
3. Ternary Operators

## Unary Operators

Unary operators are those operators that operate a single operand to form an expression. There are basically two unary operators.

• +(increment) operator
• -(decrement) operator

## Binary Operators

Binary operators are those operators that operate two or more operands to form an expression. Some of the binary operators are -,+,/,*,! etc.

Example: x+y,x*y,x-y,x/y etc.

## Ternary Operators

Ternary operators are those operators that operate a minimum of three operands. There is a single ternary operator that is available in C++. The only available ternary operator in C++ is ? that is used as a substitute for an if-else statement.

Example: x>y ? x:y

## Types of Operators in C++

1. Arithmetic operators
2. Logical operators
3. Comparison operators
4. Assignment operators
5. Bitwise operators
6. Comma operators
7. Increment and Decrement operators

### Arithmetic operators

The operators that help the programmer in a mathematical calculation is known as arithmetic operators.

 Operators Used For + Addition – Subtraction * Multiplication / Division % Modulus

Example:5+8,4*2 etc.

### Logical operators

The operators that help the programmer to connect two or more expression is known as logical operators.

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

### Comparison operators

Comparison operators are those operators that are used to compare variables. It returns the value either true or false. They are also known as relational operators.

 Operator Used For > Greater than < Less than = Is equal to != Is not equal to >= Greater than or equal to <= Less than or equal to

### Assignment operators

Assignment operators are those operators that are used to assign values to the identifier. The assignment operator used in C++ is a  “=” operator.

Example: x=5; (assigns the value 5 to x)

### Bitwise operators

Bitwise operators are those operators that operate at a bit level and allows the programmer to manipulate individual bits. They are basically used for testing or shifting bits.

 Operators Used For << Binary Left Shift Operator >> Binary Right Shift Operator & Binary AND Operator ^ Binary XOR Operator | Binary OR Operator ~ Binary One’s Complement Operator

### Comma Operators

Comma operators in C++ are used to separate variable names or expression.

Example:int x,y,z;

### Increment and Decrement Operators

Increment and Decrement operators in C++ are used to increase and decrease the values of the operand respectively.

 Operators Used For + Increment – Decrement 