Answer to Question #220686 in C++ for K Flo

Question #220686

What is the output of the following C++ code?

x = 5; y = 30;

while (x <= y)

x = x * 2;

cout << x << " " << y << endl;


1
Expert's answer
2021-07-27T04:36:02-0400

Step 1:

x=5 y=30

x=5*2

x=10 y=30

Step 2:

10<=30 (true)

x=10*2

x=20 y=30

Step 3:

20<=30 true

x=20*2

x=40 y=30

Step 4:

40<=30 false

Break loop

Result:

this code output

x=40 y=30









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