Answer to Question #258613 in C++ for Dion Martins

Question #258613

1. Consider the for-loop statement in pseudocode below and answer the following questions number = 15

do while (number >=-25)

Display “number = “, number

number = number -2

Loop


1.1 Rewrite the do while loop using a for-loop in a C++ syntax. Write only the for loop statement, do not write the other instructions inside the body of the loop.

1.2 Rewrite the do while loop above in C++ syntax.

1.3 How many times will the loop execute?

1.4 The value of number after execution of the loop.


1
Expert's answer
2021-10-30T22:39:24-0400

1.1

for (int number = 15; number >= -25; number -= 2)

1.2

int number = 15;
while (number >= -25) {
  cout << "number = " << number << endl;
  number -= 2;
}

1.3

The loop will be executed 21 times

1.4

After execution of the loop, the variable number will have a value of -27


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