ЁЯУв Too many exams? DonтАЩt know which one suits you best? Book Your Free Expert ЁЯСЙ call Now!


    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
    More IT Operating System Questions
    ask-question