You are viewing a single comment's thread. Return to all comments →
Ternary operator FTW!
string nums [10] = {"zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine"}; int start, end; cin >> start; cin >> end; for (int i = start; i <= end; i++) { cout << (i < 10 ? nums[i] : i % 2 == 0 ? "even" : "odd") << endl; }
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 →
Ternary operator FTW!