Write a C program to Convert Number to Words (1-9).
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | #include <iostream> using namespace std; int main() { int number; cout << "Enter a number between 1 and 9: "; cin >> number; switch (number) { case 1: cout << "One" << endl; break; case 2: cout << "Two" << endl; break; case 3: cout << "Three" << endl; break; case 4: cout << "Four" << endl; break; case 5: cout << "Five" << endl; break; case 6: cout << "Six" << endl; break; case 7: cout << "Seven" << endl; break; case 8: cout << "Eight" << endl; break; case 9: cout << "Nine" << endl; break; default: cout << "Invalid input. Please enter a number between 1 and 9." << endl; break; } return 0; } |
Output
Enter a number between 1 and 9:
1
One