5.0k views
5 votes
Using c++

Write a loop that counts down from 10 and displays each number. It should display "Blast off!" after it concludes. Do not display 0.

User Joel Bell
by
7.9k points

1 Answer

6 votes

Final answer:

In C++, you can use a while loop to count down from 10 and display each number until 0, and then display 'Blast off!'

Step-by-step explanation:

In C++, you can use a while loop to count down from 10 and display each number. Here's an example:

int count = 10;while(count > 0) { cout << count << endl; count--;}cout << "Blast off!" << endl;

This code initializes a variable 'count' to 10 and then executes the while loop until 'count' is greater than 0. Inside the loop, it displays the current value of 'count' and then decrements it. Finally, it displays 'Blast off!' after the loop.

User Swickblade
by
6.8k points