Chapter 5: Problem 22
Assume that the following code is correctly inserted into a program: int s = 0; for (i = 0; i < 5; i++) { s = 2 * s + i; cout << s << " "; } cout << endl; a. What is the final value of s? (i) 11 (ii) 4 (iii) 26 (iv) none of these b. If a semicolon is inserted after the right parenthesis in the for loop statement, what is the final value of \(s ?\) (i) 0 (ii) 1 (iii) 2 (iv) 5 (v) none of these c. If the 5 is replaced with a 0 in the for loop control expression, what is the final value of \(s ?\) (i) 0 (ii) 1 (iii) 2 (iv) none of these
Short Answer
Step by step solution
Key Concepts
These are the key concepts you need to understand to accurately answer the question.