Computer Science, asked by 2006abhisheksingh, 2 months ago

A program prints all the numbers from variable low to high where low < high. If low >= high then

the program prints an error message “ Sorry, limits are not valid “.​

Answers

Answered by dreamrob
1

Program in C++:

#include<iostream>

using namespace std;

int main()

{

int low, high;

cout<<"Enter the lower value : ";

cin>>low;

cout<<"Enter the higher value : ";

cin>>high;

if(low >= high)

{

 cout<<"Sorry, limits are not valid";

}

else

{

 for(int i = low; i <= high; i++)

 {

  cout<<i<<" ";

 }

}

return 0;

}

Output 1:

Enter the lower value : 17

Enter the higher value : 26

17 18 19 20 21 22 23 24 25 26

Output 2:

Enter the lower value : 26

Enter the higher value : 17

Sorry, limits are not valid

Output 3:

Enter the lower value : 17

Enter the higher value : 17

Sorry, limits are not valid

Similar questions