Answer to Question #318708 in C++ for Third five

Question #318708

Input two integers in one line, separated by a space. The first integer shall represent the starting point, and the other, the ending point.


Print out all even numbers that are within the range of the starting and ending point. Also keep in mind that the starting and ending numbers are also included in your even number evaluation!

1
Expert's answer
2022-03-28T02:29:48-0400
#include <iostream>


using namespace std;
int main() {


    int M, N;

    cout << "Enter two numbers (intervals): ";
    cin >> M >> N;


    cout << "\nEven numbers between " << M << " and " << N << " are: ";
    for (int i = M; i <= N; i++)
    {
        if (i % 2 == 0)
        {
            cout << i << " ";
        }
    }
    return 0;
}

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
APPROVED BY CLIENTS