Conditional Statements in C

  • + 0 comments
        char numberStrings[10][20] = {
            "one",
            "two",
            "three",
            "four",
            "five",
            "six",
            "seven",
            "eight",
            "nine",
            "Greater than 9"
        };
        
        int stringIndex = n > 9 ? 9 : n - 1;
    
        printf("%s", numberStrings[stringIndex]);