How are arithmetic expressions computed? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How are arithmetic expressions computed?

I have an Exam soon and there will be questions on expressions, some examples are: 1. 3 + 5 + 5/3*9 2. 6*6/6*6/6 For examples like these, I don’t know if division or multiplication is supposed to come first. For #1 , the multiplication of 9 and 3 come first but for #2, it’s 6*(6/6)*(6/6) so division would come before multiplying. How would I be sure of what comes first?

4th May 2019, 3:36 PM
Jamie Charles
3 Answers
+ 14
Simple school math trick of BODMAS can be used to evaluate the expressions. B Brackets first O Orders (ie Powers and Square Roots, etc.) DM Division and Multiplication (left-to-right) AS Addition and Subtraction (left-to-right) Therefore, 1 + 2 + 3 * 4; is 15 and 2 * 3 + 4 is 10.
4th May 2019, 4:11 PM
Danijel Ivanović
Danijel Ivanović - avatar
+ 7
Multiplication and division have the same precedence. Also don't add brackets by yourself, that way you change the precedence and the output Here's how it works : 1. 3+5+5/3*9= 8+1*9= 8+9= 17 2. 6*6/6*6/6= 36/6*6/6= 6*6/6= 36/6= 6
4th May 2019, 3:48 PM
voja
voja - avatar
- 1
Hello I am Yorqin
23rd May 2019, 3:25 PM
Yorqinjon