Answer to Question #165590 in C++ for shivam

Question #165590

Write a program to print the even numbers and numbers which are multiple of 7 from numbers between 1 to 50 by defining member function for even number outside the class and making it inline and another member function inside the class. [


1
Expert's answer
2021-03-01T16:03:12-0500
#include <iostream>
using namespace std;
int main () {
    cout << "Even numbers: ";
    for (int i = 1; i <= 50; i++) {
        if (i % 2 == 0) {
            cout << i << " ";
        }
    }
    cout << "\nMultiple of 7 numbers: ";
    for (int i = 1; i <= 50; i++) {
        if (i % 7 == 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

ranjeet
28.02.21, 05:24

we have to print even number not odd number

Leave a comment