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!

Expert's answer

#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!

LATEST TUTORIALS
APPROVED BY CLIENTS