### Arithmetic operators in C

Arithmetic operators in C performs arithmetic operations like addition , subtraction , division etc.

There are five Arithmetic operators in C. They are given below in the table.

Operators | Purpose |

+ | Addition |

- | Subtraction |

* | Multiplication |

/ | Division |

% | Remainder after integer division |

Example

Take two variables A=10 and B=3 , A has 10 assigned as an integer and B has 3 assigned as integer .

Then

A + B will give result 13

A-B will give result 7

A * B will yield 30

A/B will give 3 (actual 3. 33) But in this case 3 due to integer assumption

A%B will give 1 As 10 divided by 3 gives 1 as remainder .

Notes :

1. If one of integers have negative sign then it will be applied as per rules of mathematics like -3 *2 will give -6

2.If two operands are of different datatypes then result will be converted to more precise datatype like if 5.8/2 float/integer then it will give 2.9 float .

similarly in case of float and double result will get converted to double.

This type of conversion is called as implicit conversion of datatype. If sometime we required to manually convert from one datatype to other then that is called as explicit conversion which we will read later.

3. There is hierarchy for operations like Division > multiplication > addition > subtraction

Example :

a*b/c-d

it means (a*(b/c))-d

thus if a=3 b=6 c=2 d=1

result will be 8

But this hierarchy can be broken using parentheses

(a*b)/(c-d)

it will give result 18

In c only parentheses is valid , curly braces {} and square brackets [] have different meaning and use for c compilers.