Multiple choice technology programming languages

What will be the value of “num” after the following statements? int num; num = (5+4); num = num / 9; num = 12;

  1. 0

  2. 1

  3. 12

  4. 9

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

Following the statements sequentially: num = (5+4) assigns 9 to num. Then num = num / 9 divides 9 by 9, resulting in 0 (integer division truncates). Finally, num = 12 overwrites num with 12. The last assignment is what matters - num equals 12. Earlier calculations are irrelevant once overwritten.