166k views
4 votes
What is the value of number after the following statements execute?

int number = 10;

number += 5;
number -= 2;
number *= 3;

A) 3
B) 30
C) 15
D) 2

User Beautifull
by
7.5k points

1 Answer

3 votes

Final answer:

The final value of 'number' after the execution of the given statements is 39, which is not one of the provided options.

Step-by-step explanation:

The value of number after the statements execute can be calculated step by step. Starting with an initial value of 10, the following operations are applied in sequence:

  • number += 5 adds 5 to the current value of number, resulting in 15.
  • number -= 2 then subtracts 2, changing the value to 13.
  • Finally, number *= 3 multiplies the current value of number by 3, leading to the final value of 39

Therefore, the correct answer is none of the options provided, as the final value of number is 39.

User Ravindra Bhalothia
by
9.0k points