# Arithmetic Operators in C

Operators used for arithmetic operations like addition, subtraction, multiplication division etc. are called arithmetic operators.

Operator |
Description |
Example |
Result |

+ |
Adds both the operands |
20 + 10 |
30 |

- |
Subtracts second operand from first operand |
20 - 10 |
10 |

* |
Multiply both the operands |
20 * 10 |
200 |

/ |
Second operand divides first operand |
20 / 10 |
2 |

% |
Modulus operator, gives the remainder after division |
20 % 10 |
0 |

Modulus operator (%) is used only with integer values,not for floating points numbers and sign(+ or -) is always the sign of numerator.

Example:

3 % -2 = 1 [ Divide 3 by 2. The remainder is 1 and +ve sign from numerator]

-3 % 2 = -1 [ Divide 3 by 2. The remainder is 1 and -ve sign from numerator ]

3.0 % 1.5 = ? [invalid, modulus operator can not be used with floating point numbers]

## Arithmetic Expressions in C

An expression consisting of arithmetic operators, constants and variables to perform meaningful computation is called arithmetic expression.

For example

1.5+2-3*5 // 1, 2, 3, and 4 are operands and +, -* are arithmetic operator

2*(a+b)-4

*In which order we perform the operation is very important and final result depends on it.*

For Example : 8-4/2*3

If we perform the operation from left hand side :

8-4/2*3 = 4/2*3 = 2*3 = 6 //But 6 is not correct answer

Or.

If we perform operation from Right hand side :

8-4/2*3 = 8-4/6 = 8-0 = 8 // Even 8 is not correct answer

So the correct way is:

8-4/2*3 = 8-2*3 = 8-6 =2 // Using BODMAS rule, 2 is correct answer

BODMAS rule for arithmetic expression evaluation

**B**racket will have the first precedence
**O**f operator will have the second precedence
**D**ivision operator will have the third precedence
**M**ultiplication operator will have the fourth precedence
**A**ddition operator will have the fifth precedence
**S**ubtraction operator will have the sixth precedence