C++ Program to Enter a Number and Print it into Words using Switch Case

C++ Program to Enter a Number and Print it into Words using Switch Case : we Start to write a program about number.

C++ Program to Enter a Number and Print it into Words using Switch Case

#include <iostream>
using namespace std;
int main()
{
    int n, num = 0, i;
    cout << "\n\n Print a number in words:\n";
    cout << "-----------------------------\n";
    cout << " Input any Number: ";
    cin >> n;
    while (n != 0) {
        num = (num * 10) + (n % 10);
        n /= 10;
    }
    for (i = num; i > 0; i = i / 10) {

        switch (i % 10) {
        case 0:
            cout << "Zero ";
            break;
        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;
        }
    }
    cout << endl;
}

Output of Program

Print a number in words:

Input any Number: 40253
Four Zero Two Five Three