How to work operators? | Sololearn: Learn to code for FREE!


How to work operators?

How to work operators, Left to right or right to left?

1/17/2022 2:23:47 AM

Anjali Kumari

8 Answers

New Answer


operator precedence defines the order in which operators are evaluated, If there are multiple operators of same precedence, the evaluation is done on the basis of their associativity. This is generally same as what you would find in traditional maths ( following the BODMAS rule for precedence ) but languages are free to alter them according to their needs ( although there are only a few exceptions where they actually do that ), so it's preferred to actually look up a reliable docs of the language you are using to know the right precedence and associativity. for example (C++) :


Here is what BODMAS stands for: B--> Brackets O--> Order of powers or roots D--> Division M--> Multiplication A--> Addition S--> Substraction


Left to right if they have same operator precedence.


If they not same precedence?


Though boadmas and ofcourse use parenthesis () to solve each of them to resolve with ease..




B--> Brackets O--> Order of powers11 DM--> Divisions and Multiplications left to right AS--> Additions and Substractions left to right


BODMAS Bracket Power Divide Multiply Add Sub