# Operators in C

Operators are used to perform operations on variables . Common operations includes addition, subtraction, multiplication, division etc.

There are various types of operators in C :-Operators | Description |
---|---|

* / % + - | Arithmetic Operators |

!= > < >= <= ==/td> | Relational Operators |

&& || ! | Logical Operators |

&, |, ^, ~, >> << | Bitwise Operators |

+=, -=, *=,= | Assignment Operators |

conditional, comma, sizeof, address, redirecton | Other Operators |

## Hierarchy of Operations

There are various scenarios where compiler has to know which operation should it performs first. What do you think this expression will be evaluated according to compiler ?

2 * x - 3 * y

Now,

There are two ways to solve this equation

1) (2x)-(3y) 2) 2(x-3y)

We engineers know how to solve these problems because we know multiplication is solved first then minus operation should be applied.
**But how does compiler know how to solve this ?** So Hierarchy of Operations helps compiler to understand these kind of equations.

## Following table list the operators according to priorities :-

Priority | Operators | Description |
---|---|---|

1^{st} |
*/% | multiplication, division, modular division |

2^{nd} |
+- | addition, subtraction |

3^{rd} |
= | assignment |

## What this table signifies ?

* will be always solved first then division (/) operator . + will be solved before - operator but * will be solved first then + operator.

## Example

a = 2*3/4+4/4

As ***** has max priority than **'/'** So it will be evaluated first. So,

6/4+4/4

Now **'/'** has max priority than **'+'** so

1 + 4/4

Now **'/'** has max priority than **'+'** so

1 + 1

Result is 2

## Solve the Quiz of Article

**
**

**codzify.com**

Largest collection of up-to-date tutorials to learn programming languages. We are focused on easy learning. Massive collection of interview questions one may need for preparation.

**Tutorials Library**

C, C++, Java, Python Data Structures, Swift, Objective C, Swift iOS, iOS Objective C, Socket.Io, Android, Extras by Codzify.