Answer to Question #261418 in C++ for Syarah

Question #261418

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.

1
Expert's answer
2021-11-05T01:12:53-0400
#include<iostream>
using namespace std;
int main(){
	cout<<"Enter the first number:\n";
	int n1;
	cin>>n1;
	cout<<"Enter the second number:\n";
	int n2;
	cin>>n2;
	cout<<"Even numbers between "<<n1<<" and "<<n2<<" are:\n";
	for(int i=n2; i>= n1; i--){
		if(i%2==0){
			cout<<i<<endl;
		}
	}
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS