solve using operator predesence int a = 2, b = 6; int result = b / a + b %solve a;
Answers
Answered by
2
Operator precedence is -- Brackets, division, multiplication, then addition or subtraction since both of them have equal precedence.
Value of int a = 2
Value of int b = 6
Let us convert it in a côde--
int a = 2;
int b = 6
int result = b / a + b % a;
System.out.print(result);
Now let us answer it step by step--
- b / a => 6 / 2 = 3
- 3 + b % a => b % a => 6 % 2 = 3
- 3 + 3 = 6
Therefore, 6 is our answer.
Note:-- % is used for obtaining remainder.
I hope that my answer helps you...
Similar questions