You are viewing a single comment's thread. Return to all comments →
int main() { string spelledOut[9] = {"one", "two", "three", "four", "five", "six", "seven", "eight", "nine"}; int num1, num2; cin >> num1; cin >> num2; for (int i = num1; i <= num2; i++) { if (i >= 1 && i <= 9) { cout << spelledOut[i-1] << endl; } else if (i % 2 == 0) { cout << "even" << endl; } else { cout << "odd" << endl; } } return 0; }
int main() {
string spelledOut[9] = {"one", "two", "three", "four", "five", "six", "seven", "eight", "nine"}; int num1, num2; cin >> num1; cin >> num2; for (int i = num1; i <= num2; i++) { if (i >= 1 && i <= 9) { cout << spelledOut[i-1] << endl; } else if (i % 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 →