# Operators

Imagine if you want to add the two numbers 10200 and 23345. What you will do ?

You will add this using calculator or by self right.

If you need to add something or do some calculations in programming, you can use operators.

So Operators are symbols like +, -, /, etc which are used to perform some operations.

## Different types of operators are,

- Assignment operator
- Arithmetic operator
- Relational operator
- Unary operator
- Bitwise operator
- Logical operator
- Ternary operator

Variable and datatypes will be explained elaborately in upcoming topics.

## Assignment operators

Assignment operator is a operator which is used to assign or initialize a value.

### Example

main(){

int a=5;

}

In the above example,

int - datatype

a - variable

= - assignmet operator

## Arithmetic operators

Arithmetic operators are operators which perform arithmetic operations like addition, subtraction, multiplication, modulo and division.

### Example

main(){

int a=5+6;

}

In the above example,

int - datatype

a - variable

= - assignmet operator

+ - arithmetic operator.

### Different arithmetic operators are,

**+** - addition

**-** - subtraction

***** - multiplication

**/** - division

**%** - modulo

Modulo is used to find remainder of the divided value.

## Relational operators

Relational operators are operators which are used to compare two items. e.g. <, >, <=, >=

### Different relational operators are,

**>** - greater than

**<** - greater than or equal to

**>=** - less than

**<=** - less than or equal to

**==** - equal to

**!=** - not equal to

### Example

a>b

## Unary operators

Unary operators are operators which can contain only single operand.It is used to increment or decrement a value.

increment(++) - increasing the value.

decrement(--) - decreasing the value.

### Example

i++

In the above example,

i - variable or operands

++ - unary operator

## Bitwise operators

In some situations, we may need to perform operations based on bits od data. This is known as bitwise operator.

& - bitwise AND.

| - bitwise OR.

^ - bitwise XOR.

~ - negative pr complement of the value.

<< or >> - right shift the bit or left shift the bit.

### Example

a&b

In the above example,

a and b - variables or operands

& - bitwise operator

## Logical operators

Logical operators are operators which may be used to combine two decisions to get a single decision in either 0 or 1.

&& - logical AND.

|| - logic OR.

! - logical NOT.

### Example

((a>b)&&(b>c))

In the above example,

a and b - variables or operands

& - bitwise operator

**Ternary operator**

Ternary operator is the operator which combines if else condition in one line.

?: - Ternary operator or condition.

### Example

(a>b)?1:0

In the above example,

a and b - variables or operands

> - relational operator

If a is greater than b i.e. if condition is true, then statements after '?' will execute. if fails then statements after ':' will be executed.