I'm really fond of even numbers, you know? That's why I'll be letting you make another even number problem yet again. This time, you need to print from a range of two inputted numbers, n1 and n2 (inclusive), all the even numbers from n2 down to n1, in descending order.
How about that?
#include<iostream>
using namespace std;
int main(){
int i,s,n;
cout<<"\nEnter the starting number in the range:";
cin>>s;
cout<<"\nEnter the ending number in the range:";
cin>>n;
cout<<"Even numbers in descending order in the range "<<s<<" to "<<n<<"\n";
for(i=n;i>=s;i--){
if(i%2 == 0){
cout<<i<<"\t";
}
}
}
Comments
Leave a comment