Consider the expression given below: x = a + b * (c − d) / e + f % g;
Consider the expression given below:
x = a + b * (c − d) / e + f % g;
The variables have the following values:
a = 8, b = 5, c = 10, d = 3, e = 2, f = 7, g = 3;
If the variables x, a, b, c, d, e, f, g are of integer data type, then what will be the value of x after evaluating the above expression?
Show answerHide answer
Correct answer: (B) 26
Explanation
b * (c − d) = 5 × 7 = 35, and 35 / 2 = 17 in integer division. f % g = 7 % 3 = 1. So x = 8 + 17 + 1 = 26.