C++ Program for Print Number to Word

Master C++ with Real-time Projects and Kickstart Your Career Start Now!!

Program 1

// Program to print word format of number
#include<iostream>
using namespace std;
int main()
{  
    int n,r,s=0;
    cout<<"Enter a number";
    cin>>n;
    system("cls");
    // Reverse of number
    while(n!=0)
    {
         r=n%10;
         s=s*10+r;
         n=n/10; 
    }
    while(s!=0)    
    {
        r=s%10;
        switch(r)
        {
            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;
        }
        s=s/10;
    }
}

 

You give me 15 seconds I promise you best tutorials
Please share your happy experience on Google

courses

TechVidvan Team

TechVidvan Team provides high-quality content & courses on AI, ML, Data Science, Data Engineering, Data Analytics, programming, Python, DSA, Android, Flutter, full stack web dev, MERN, and many latest technology.

Leave a Reply

Your email address will not be published. Required fields are marked *