C++ language

adplus-dvertising
Program To Print Digits Of Number
Previous Home Next

A program to input any number and write all the digits in words

#include<stdio.h>
#include<conio.h>
void main()
{
int num,a;
cout<<"\n Enter the number";
cin>>num;
while(num!=0)
{
a=num%10;
num=num/10;
switch(a)
{
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 10 :cout<<"zero";
break;
}
}
}

Output:

396
three nine six
Previous Home Next