+ 6
How to work operators?
How to work operators, Left to right or right to left?
8 Answers
+ 5
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++) :
https://en.cppreference.com/book/operator_precedence
+ 4
Here is what BODMAS stands for:
B--> Brackets
O--> Order of powers or roots
D--> Division
M--> Multiplication
A--> Addition
S--> Substraction
+ 3
Left to right if they have same operator precedence.
+ 3
If they not same precedence?
+ 3
Though boadmas and ofcourse use parenthesis () to solve each of them to resolve with ease..
+ 2
BODMAS
+ 2
B--> Brackets
O--> Order of powers11
DM--> Divisions and Multiplications left to right
AS--> Additions and Substractions left to right
+ 1
BODMAS
Bracket
Power
Divide
Multiply
Add
Sub