Question #92975

What will be printed by the following code?

int x=4;
repeat(4){ x = 2 * x + 3; }
cout << x << endl;

Expert's answer

Initial value of x=4

repeat(4){ x = 2 * x + 3; } 

This line means the mathematical operation is done for 4 times.

First:

Put x=4

x=2*4+3=11

Now value of x=11

Second:

Put x=11

x=2*11+3=25

Now value of x=25

Third:

Put x=25

x=2*25+3=53

Now value of x=53

Fourth:

Put x=53

x=2*53+3=109

Now value of x=109

Hence ,after execution of code

the following is printed:

109


Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

LATEST TUTORIALS
APPROVED BY CLIENTS