You are viewing a single comment's thread. Return to all comments →
ofcourse there are better sophisticated ways of making the code shorter and more flexiable but here is nothing that works too but fails lol int main() { int n; cout << "Enter your digit:"; cin >>n; if (n == 1) { cout << "one" << endl; } if (n == 2 ) { cout << "two" << endl; } if (n == 3) { cout << "three" << endl; } if (n == 4) { cout << "four" << endl; } if (n == 5) { cout << "five" << endl; } if (n == 6) { cout << "six" << endl; } if (n == 7) { cout << "seven" << endl; } if (n == 8) { cout << "eight" << endl; } else if ( n > 9) { cout << "n=" << n << " " << "is greater than 9" << endl; } return 0; }
Seems like cookies are disabled on this browser, please enable them to open this website
Conditional Statements
You are viewing a single comment's thread. Return to all comments →
ofcourse there are better sophisticated ways of making the code shorter and more flexiable but here is nothing that works too but fails lol int main() { int n; cout << "Enter your digit:"; cin >>n; if (n == 1) { cout << "one" << endl; } if (n == 2 ) { cout << "two" << endl; } if (n == 3) { cout << "three" << endl; } if (n == 4) { cout << "four" << endl; } if (n == 5) { cout << "five" << endl; } if (n == 6) { cout << "six" << endl; } if (n == 7) { cout << "seven" << endl; } if (n == 8) { cout << "eight" << endl; } else if ( n > 9) { cout << "n=" << n << " " << "is greater than 9" << endl; } return 0; }