#include <iostream>
using namespace std;
int main()
{
string s[] = {"one", "two", "three", "four", "five", "six", "seven", "eight", "nine"};
int a, b;
cin >> a >> b;
for (int i = a; i <= b; i++)
(i >= 1 && i <= 9) ? printf("%d\n", s[i - 1]) : i % 2 ? printf("odd\n") : printf("even\n");
return 0;
}
I am using a ternary operator to print integer into word if it lies between 1 to 9 otherwise printing whether it's even or odd. I am not able to use cout in ternary operator and if I used printf then it's printing a character. can anybody tell me how to do that. I wanted to do the entire stuff in one line, is it possible?