19.9k views
1 vote
Write a program that takes in an integer in the range 20-98 as input. The output is a countdown starting from the integer, and stopping when both output digits are identical.

User Limitrof
by
4.7k points

1 Answer

2 votes

Answer:

Following are the program in c++ langauge

#include<iostream>

using namespace std; // namespace

int main() // main function()

{

int n1; // variable declaration

cout<<"Enter the number between 20 and 98 :";

cin>>n1;// Read the value by user

cout<<" The output is given :93 92 90 89 88

Explanation:

Read the value by user in the n1 variable of int type" ;

if(n1 < 20 || n1 > 98) // checking the condition

{

cout<<" input must be between the 20-98";

}

else

{

cout<<n1; // display the value of n1

while(n1 % 11 != 0) // itearting over the loop

{

n1 = n1 - 1; // decrement the value of n1 by 1

cout<<" "<< n1; // didplay the n1

}

}

}

Output:

Enter the number between 20 and 98 :93

The output is given :93 92 90 89 88

Explanation:

Following are the description of the program

  • Read the value by user in the "n1" variable of int type.
  • In the if block checking the range of input .
  • If the user puts the correct range then control goes to the else block and calculating the countdown.
User Arib Yousuf
by
4.6k points