You are viewing a single comment's thread. Return to all comments →
using namespace std;
int main() { // Complete the code. int a,b; cin >> a >> b ; for(int i = a; i <= b; i++) { int n = i; if (n == 1) { std::cout << "one" << endl; } else if (n == 2) { std::cout << "two" << endl; } else if (n == 3) { std::cout << "three" << endl; } else if (n == 4) { std::cout << "four" << endl; } else if (n == 5) { std::cout << "five" << endl; } else if (n == 6) { std::cout << "six" << endl; } else if (n == 7) { std::cout << "seven" << endl; } else if (n == 8) { std::cout << "eight" << endl; } else if (n == 9) { std::cout << "nine" << endl; } else { if(n%2==0){ cout <<"even" << endl; } else{ cout << "odd" << endl; } }
} return 0; }
Seems like cookies are disabled on this browser, please enable them to open this website
For Loop
You are viewing a single comment's thread. Return to all comments →
include
include
using namespace std;
int main() { // Complete the code. int a,b; cin >> a >> b ; for(int i = a; i <= b; i++) { int n = i; if (n == 1) { std::cout << "one" << endl; } else if (n == 2) { std::cout << "two" << endl; } else if (n == 3) { std::cout << "three" << endl; } else if (n == 4) { std::cout << "four" << endl; } else if (n == 5) { std::cout << "five" << endl; } else if (n == 6) { std::cout << "six" << endl; } else if (n == 7) { std::cout << "seven" << endl; } else if (n == 8) { std::cout << "eight" << endl; } else if (n == 9) { std::cout << "nine" << endl; } else { if(n%2==0){ cout <<"even" << endl; } else{ cout << "odd" << endl; } }
} return 0; }