How do you evaluate this ?
- May 19th, 2012
- By ArafatX
- Write comment
6/2(1+2)
The answer is 1 or 9?
6/2(1+2)
1) 6/2(3)
2) 6/6
3) Answer: 1
That’s it… or..
6/2(1+2)
1) 6/2(3)
2) 3(3)
3) Answer: 9
The correct answer is on how you evaluate the operator precedence. If you think the operator of division and multiplication have the same precedence, then you evaluate it from the right (division) to the left (multiplication), so your answer is 1 but if you think the multiplication has the higher precedence compared to division, then your answer is 9. In some programming languages, such as C++, it treats the multiplication operator as higher precedence over division. So, a C++ programmer will answer it as 9. Engineer students should agree with this. So let’s redo:
1)
2)
3)
4) Answer: 9
============= MaXi32 ===========



