Respuesta :
Answer:
Option B 120
Explanation:
There are three variables, ans, x and y given in the code. In beginning, the variable. ans, holds value of 10. And variable x and y hold value of 65 and 55, respectively. Since the value held by x is bigger than one held by y, the if condition is met and the statement ans = x + y will run. The execution of this statement will total x with y -> 65 + 55 and the initial value of ans is overwritten by the addition result which is 120.
Answer:
B) 120
Explanation:
In the first three lines of the code, three variables ans, x and y have been declared and initialized;
=> ans = 10;
=> x = 65;
=> y = 55;
On the fourth line and fifth line of the code, there is an if block statement that will get executed if the value of x is greater than or equal to that of y;
i.e
if (x >= y)
ans = x + y;
And since x = 65 and y = 55, it implies that x is greater than or equal to y.
Therefore the fifth line of the code will be executed
=> ans = x + y
=> ans = 65 + 55
=> ans = 120
Note:
Though the value of variable ans was initially 10 before the execution of the if statement, its new value 120 will replace the former value.
Therefore the value of ans after the code has been executed is 120