C++Program to Convert Digits/Number to Words
Here you will get an example code of C++ Program to Convert Digits/Number to Words. This is an easy program for printing the number or digits in words.
For Example:
Input : 56784
Output : Five Six Seven Eight Four
Program Code to Convert Digits/Number to Words
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 | #include<iostream> using namespace std; int main() { char num[20]; int i=0; cout << "Input any number : "; cin >> num; while(num[i]!='\0') { switch(num[i]) { case '1': cout<<"One ";break; case '2': cout<<"Two ";break; case '3': cout<<"Three ";break; case '4': cout<<"Four ";break; case '5': cout<<"Five ";break; case '6': cout<<"Six ";break; case '7': cout<<"Seven ";break; case '8': cout<<"Eight ";break; case '9': cout<<"Nine ";break; case '0': cout<<"Zero ";break; } i++; } return 0; } |
Output
Input any number : 56784
Five Six Seven Eight Four
Check out our other C++ programming Examples