Loop control expression

Assume that the following code is correctly inserted into a program:  (4) 

int num = 1;

int count;

for (count = 0; count < 5;=””>

    num = 2 * num + num % (count + 1);

a. What is the final value of num? 

(i) 15                      (ii) 42                     (iii) 26                    (iv) none of these

b. If a semicolon is inserted after the right parentheses in the for loop statement, what is the final value of num? 

(i) 1                        (ii) 2                       (iii) 3                      (iv) 4                      (v) none of these

c. If 5 is replaced with 0 in the for loop control expression, what is the final value of num? 

(i) 0                        (ii) 1                       (iii) 2                      (iv) none of these

Posted in Uncategorized

Leave a Reply