Conditional Statements

  • + 10 comments

    No need for any if statements:

    int n;
    const char *words[] = {"one","two","three","four","five","six","seven","eight","nine"};
    cin >> n;
    cout << ((n<= 9) ? words[n-1] : "Greater than 9") << endl;