Given the code fragment:
What is the result?
Given the code fragment:
What is the result?
The initial value of variable i is 10, and the initial value of j is 5. The code fragment i += (j * 5 + i) / j - 2; follows the order of operations as per BODMAS/BIDMAS rules (Brackets, Orders (i.e., powers and square roots, etc.), Division and Multiplication, Addition and Subtraction). Firstly, evaluate j * 5, which is 5 * 5 = 25. Next, add the value of i, which is 10, resulting in 25 + 10 = 35. Then, divide 35 by j, which is 5, so 35 / 5 = 7. Finally, subtract 2 from 7, giving 7 - 2 = 5. Adding this result to the initial value of i, 10 + 5 = 15. Therefore, the result is 15.
C is correct
Correct answer is C. BODMAS
i = 10+((5*5+10)/5 - 2)
C is correct tested
var i = 10; var j = 5; i += (j*5 +i)/j-2; System.out.println(i); //15 => 10+(35/5)-2 = 15
Tested: C.
C ans = i+35/5-2 = 15
Answer:C
i+=(5*5+10)/5-2, so i+=5 is 15)
C is Correct