+ 1

I aspect "0" as output in this code. Based on "BODMAS" .But I get "2" as output why?

BODMAS https://code.sololearn.com/c2ro5e4j1PSL/?ref=app

18th Nov 2022, 12:34 AM
Yogeshwaran P
Yogeshwaran P - avatar
3 Answers
+ 4
Yogeshwaran According to bodmas ... content inside brackets work first If you change the code as 3*(4/5)-->. You get 0 as output...
18th Nov 2022, 5:28 AM
Riya
Riya - avatar
+ 4
3 * 4 = 12 12 / 5 = 2.4 so you cast to int that means remove everything after the '.' and the result is 2
18th Nov 2022, 1:22 AM
Giannis
Giannis - avatar
+ 2
I hear 1st time about the BODMAS, But i think you need to see the colors and not the letters. https://images.app.goo.gl/vwSM3RyoxVTNoX8j9 multiply and division has exactly same priority, so you do 1st what is the most left
18th Nov 2022, 1:28 AM
Giannis
Giannis - avatar