Write code that prints: Ready! userNum ... 2 1 Blastoff! Your code should contain a for loop. Print a newline after each number and after each line of text Ex: userNum = 3 outputs: Ready! 3 2 1 Blastoff!

Respuesta :

Answer:

The program to this can be described as follows:

Program:

#include <iostream> //defining header file

using namespace std;

int main() //defining main method

{

int number,l,value=0; //defining integer variables

cout<<"UserNum = "; //print message

cin>>number; //input value by user-end

cout<<"Ouput: Ready!"<<endl<<number<<endl; //print input value with message

for(l=1;l<number;l++) //loop print value in reverse order

{

value=number-l; //calculate value

cout<<value<<endl; //print value

}

cout<<"Blastoff!"; //print message

return 0;

}

Output:

UserNum = 3

Ouput: Ready!

3

2

1

Blastoff!

Explanation:

Description of the above code:

  • Three integer variable "number, l, and value=0" is defined in this program, in which the number variable takes input from the end and the variable l and value is used in the loop to calculate the value in reverse order.
  • In the for loop is declared, a variable value is defined, which calculates the value in reverse order and uses a print method to print the value.