# On the operator

What is the operator precedence and associativity??

Precedence means flow of execution (means which one will perform 1st),
It is similar to BODMAS rule but in programming language multiple(*) or divide (/) having same precedence and add (+) or subtract (-) having same precedence .

Associativity means order of execution (i.e. left to right)

Now understanding via example:

(i) 2+1-1 (1st addition will perform then substruction)
(ii) 2-2+1(1st subtraction will perform then addition)
(iii) 126/3 (1st multiplication then division)
(iv) 12/6
3 (1st division then multiplication)

in above example all are executing left to right and having same priority of division and multiplication or addition and subtraction

(v) 3/2-32+23-2/2 (1st division of 3/2, then multiplication of 32, then again multiplication of 23, then next division takes place (2/2), then subtraction of (3/2)-(32), then addition of {(3/2)-(32)}+(23), then again subtraction of [{(3/2)-(32)}+(2*3)]-(2/2).

in example (v) execution occurred left to right(as per Associativity rule) a but multiplication or division group execute first and then subtraction or addition group takes placed (as per Precedence rule).