# Operators In C++ | Topic 4 | VU Insider

Operators are used to perform different type of operations on variables and values. In C++, operators are divided into following groups:
• Arithmetic Operators
• Assignment Operators
• Comparison Operators
• Logical Operators

## Arithmetic Operators

Arithmetic operators are used to perform basic mathematical operations like addition, subtraction, division etc.

### List of Arithmetic Operators

Name(sign)ExampleDetails
Subtraction(-)x-ysubtracts two values
Multiplication(*)x*ymultiplies two values
Division(/)x/ydivides one value from another
Modulus(%)x%yreturns the remainder
Increment(++)x++increase value by one
Decrement(--)x+ydecrease value by one

Example: int x = 10 + 20; // 30 (10 + 20)
int y = x - 10; // 20 (30 - 10)
int z = x + y; // 50 (30 + 20)code-box

## Assignment Operators

These operators are used to assign values to variables. For example, we have to assign the value 10 to variable x. We can write it as;
int x = 10;

SignExampleMean
=x=10x=10
+=x+=10x=x+10
-=x-=10x=x-10
*=x*=10x=x*10
/=x/=10x=x/10
%=x%=10x=x%10
&=x&=10x=x&10

## Comparison Operators

The operators used to compare two values. Comparison operators either return 1 or 0 as the return value. 1 means true and 0 means false.

The following example will tell us if x is greater then y. int x = 10;
int y = 5;
cout << (x>y); // it returns 1(true) as 10 > 5code-box

### List of Comparison Operators

SignNameExample
==Equal tox == y
!=Not equal tox != y
">"Greater then"x > y"
"<"Less then"x < y"
">="Greater then or equal to"x >= y"
"<="Less then or equal to"x <= y"

## Logical Operators

Operators used to determine the logic between variables.

### List of Logical Operators

Name (sign)ExampleDetails
Logic AND (&&)"x<10 td="" x="">Returns if both statements are true
Logic OR(||)"x<10 td="" x="">Returns if one of statements is true
Logic NOT(!)"!(x<10 td="" x="">Returns false if result is true