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. [
#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;
}
Comments
we have to print even number not odd number
Leave a comment