📢 Too many exams? Don’t know which one suits you best? Book Your Free Expert 👉 call Now!

  • google app store apple app store
  • ✖

      Question

      What is the final value of x after the following C++

      code snippet executes?     int x = 10;     for (int i = 0; i < 3; ++i) {         x += i;     }     // Assume x is accessible here
      A 10 Correct Answer Incorrect Answer
      B 11 Correct Answer Incorrect Answer
      C 12 Correct Answer Incorrect Answer
      D 13 Correct Answer Incorrect Answer
      E 16 Correct Answer Incorrect Answer

      Solution

      Initial: x = 10     i = 0: x = 10 + 0 = 10     i = 1: x = 10 + 1 = 11     i = 2: x = 11 + 2 = 13     Loop ends. Final x = 13.

      Practice Next
      ask-question