# Operators in C++ | Unary and Binary operators

Operators are the symbols that are used to perform certain operations on **data**. C++ provides a variety of operations. These include **arithmetic operations**, **relational operations**, **logical operators**, **increment and decrement operator,** and **assignment operators**. The operations can be categorized as follows:

**Unary Operators** **in C++**

A type of operator that works with one operand is known as a unary operator. The following operators are unary operators.

**-, ++, —**

The above operators are with one operand as follows.

-a;

N++;

–x;

**Binary Operations** **in C++**

A type of operator that works with two operands is known as binary operators

+, -, /, %

The above operators are used with two operands as follows:

a + b;

a / y

**Arithmetic Operators** **in C++**

Arithmetic operators are a symbol that performs mathematical operations on data. C++ provides many arithmetic operators.

Operation | Symbol | Description |

Addition | + | Add two values |

Subtraction | – | Subtract one value from another |

Multiplication | * | Multiplies two values |

Division | / | Divides one value by another value |

Modulus | % | Gives the remainder of the division of two integers |

**Increment Operator** **in C++**

The increment operator is used to increase the value of the variable by 1. It is denoted by the symbol ++. It is a unary operator and works with a single variable.

The increment operator cannot increment the value of constants and expressions. For example, A++ and X++ are valid statements but 10++ is an invalid statement.

**Increment operator can be used in two forms:**

- Prefix Form
- Postfix Form

**Decrement Operator**

The decrement operator is used to decrease the value of a variable by 1. It is denoted by the symbol –. It is a unary operator and works with a single variable.

The decrement operator cannot decrement the value of constants and expressions. For example, A– and X — are valid statements but 10– is an invalid statement.

**It can also use two forms**

- Prefix Form
- Postfix Form

**Assignment Operators**

An operator that assigns a value to a variable is known as an assignment statement. Assignment operator = is used in assignment operator to assign a value or computational result to a variable.

**Relational Operator**

The relational operator is used to find the relationship between two operands. E.g.

a > b, b > a

**Logical Operators**

Logical operators perform simplest on Boolean values (or expressions like relational operators that go back to Boolean values) and yield a Boolean end result on their own. The operators used for logical computation in C++ are !, &&, and ||.

**Bitwise Operators**

Bitwise operators are used to perform operations on the integer data at the single bit level.

**For Example: **a & b; a | b;

## Leave a Reply