Answer to Question #92975 in C++ for Shivaprasad

Question #92975
What will be printed by the following code?

int x=4;
repeat(4){ x = 2 * x + 3; }
cout << x << endl;
1
Expert's answer
2019-08-21T15:15:42-0400

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!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS