+ 4

# Math question for Ruby

What is the output of 5-2*3+3? I think, it is 4, but the answer is 2, I don't understand

6th Jan 2017, 9:54 PM
Anderson Farid Palacio Agudelo + 8
5-2*3+3 first the 2*3 will execute which will be 6 now we've got: 5-6+3 5-6 is -1 -1+3 is 2 easy ^^
6th Jan 2017, 10:20 PM
Kamil + 8
That's because of the highest priority of the multiplication operator... If you're not sure, use parenthesis to get the expected result ^^
7th Jan 2017, 2:56 AM
visph + 4
2 * 3 = 6 5 - 6 = -1 -1 + 3 = 2
8th Jan 2017, 10:16 AM
Carmelo
+ 4
@Greg Oboroceanu: Addition and substraction are done from left to right priority ^^
2nd Feb 2017, 11:24 AM
visph + 3
15th Jan 2017, 2:57 AM
CHUN
+ 2
ohhh yeah thank you!!! :)
6th Jan 2017, 11:08 PM
Anderson Farid Palacio Agudelo + 2
20th Jan 2017, 11:26 AM
Renice Owino + 2
5-2*3+3 =5-(2*3)+3 (multiply is priorité to make) =5-6+3 (they group the positive numbers =5+3-6 and the negaitve number) =8-6 (then, thay execute them) =2. ( finally, answers is 2)
21st Jan 2017, 1:43 PM
CHUN
+ 1
* and / are operated first
10th Jan 2017, 9:53 AM
Alvaro Wenceslao Ponce + 1
=5-2*3+3 =5-6+3 {multiply 2 and 3} =-1+3 =2 So, 2 is the answer.
11th Jan 2017, 4:54 AM
Balwinder Kumar + 1
the Answer will be 2 positive
14th Jan 2017, 6:51 AM
Tiptop
+ 1
yeah it's 2 as firstly -2*3= -6 and then 5+3=8 so basically -6+8=2
20th Jan 2017, 3:12 PM
harshcr7
+ 1   