<br />#include<iostream> using namespace std; int main() { int a,c,i=0; int b[6]; cout<<"Enter the number="; cin>>a; if(a==0) { cout<<"Zero"; exit; } while(1) { b[i]=a%10; a=a/10; if(a==0) { break; } i++; } while(i>0) { if(i==5) { switch(b[i]) { case 1: { cout<<"one lakh "; i--; break; } case 2: { cout<<"two lakh "; i--; break; } case 3: { cout<<"three lakh "; i--; break; } case 4: { cout<<"four lakh "; i--; break; } case 5: { cout<<"five lakh "; i--; break; } case 6: { cout<<"six lakh "; i--; break; } case 7: { cout<<"seven lakh "; i--; break; } case 8: { cout<<"eight lakh "; i--; break; } case 9: { cout<<"nine lakh "; i--; break; } default: { i--; break; } } } if(i==4) { if(b[3]==0) { switch(b[4]) { case 1: { cout<<"ten thousand "; i--; break; } case 2: { cout<<"twenty thousand "; i--; break; } case 3: { cout<<"thirty thousand "; i--; break; } case 4: { cout<<"forty thousand "; i--; break; } case 5: { cout<<"fifty thousand "; i--; break; } case 6: { cout<<"sixty thousand "; i--; break; } case 7: { cout<<"seven thhousand "; i--; break; } case 8: { cout<<"eight thousand "; i--; break; } case 9: { cout<<"ninty thousand "; i--; break; } default: { i--; } } } else { if(b[4]==1) switch(b[3]) { case 1: { cout<<"eleven thousand "; i--; i--; break; } case 2: { cout<<"tweleve thousand "; i--; i--; break; } case 3: { cout<<"thirteen thousand"; i--; i--; break; } case 4: { cout<<"fourteen thousand "; i--; i--; break; } case 5: { cout<<"fifteen thousand "; i--; i--; break; } case 6: { cout<<"sixteen thousand "; i--; i--; break; } case 7: { cout<<"seventeen thousand "; i--; i--; break; } case 8: { cout<<"eighteen thousand "; i--; i--; break; } case 9: { cout<<"nineteen thousand "; i--; i--; break; } default: { i--; break; } } else { switch(b[4]) { case 2: { cout<<"twenty "; i--; break; } case 3: { cout<<"thirty "; i--; break; } case 4: { cout<<"forty "; i--; break; } case 5: { cout<<"fifty "; i--; break; } case 6: { cout<<"sixty "; i--; break; } case 7: { cout<<"seventy "; i--; break; } case 8: { cout<<"eighty "; i--; break; } case 9: { cout<<"ninty "; i--; break; } default: { i--; break; } } } } } if(i==3) { switch(b[3]) { case 1: { cout<<"one thousand "; i--; break; } case 2: { cout<<"two thousand "; i--; break; } case 3: { cout<<"three thousand "; i--; break; } case 4: { cout<<"four thousand "; i--; break; } case 5: { cout<<"five thousand "; i--; break; } case 6: { cout<<"six thousand "; i--; break; } case 7: { cout<<" seven thousand "; i--; break; } case 8: { cout<<"eight thousand "; i--; break; } case 9: { cout<<"nine thousand "; i--; break; } default: { i--; break; } } } if(i==2) { switch(b[2]) { case 1: { cout<<"one hundred "; i--; break; } case 2: { cout<<"two hundred "; i--; break; } case 3: { cout<<"three hundred "; i--; break; } case 4: { cout<<"four hundred "; i--; break; } case 5: { cout<<"five hundred "; i--; break; } case 6: { cout<<"six hundred "; i--; break; } case 7: { cout<<"seven hundred "; i--; break; } case 8: { cout<<"eight hundred "; i--; break; } case 9: { cout<<"nine hundred "; i--; break; } default: { i--; break; } } } if(i==1) { if(1) { switch(b[1]) { case 1: { if(b[0]==0) { cout<<"ten "; i--; } break; } case 2: { cout<<"twenty "; i--; break; } case 3: { cout<<"thirty "; i--; break; } case 4: { cout<<"forty "; i--; break; } case 5: { cout<<"fifty "; i--; break; } case 6: { cout<<"sixty "; i--; break; } case 7: { cout<<"sevety "; i--; break; } case 8: { cout<<"eighty "; i--; break; } case 9: { cout<<"ninty "; i--; break; } default: { i--; break; } } } if(b[1]==1) { switch(b[0]) { case 1: { cout<<"eleven "; i--; break; } case 2: { cout<<"twelve "; i--; break; } case 3: { cout<<"thirteen "; i--; break; } case 4: { cout<<"forteen "; i--; break; } case 5: { cout<<"fifteen "; i--; break; } case 6: { cout<<"sixteen "; i--; break; } case 7: { cout<<"seventeen "; i--; break; } case 8: { cout<<"eighteen "; i--; break; } case 9: { cout<<"nineteen "; i--; break; } default: { i--; break; } } } } if(i==0&&b[1]!=1) { switch(b[0]) { case 1: { cout<<"one"; i--; break; } case 2: { cout<<"two"; i--; break; } case 3: { cout<<"three"; i--; break; } case 4: { cout<<"four"; i--; break; } case 5: { cout<<"five"; i--; break; } case 6: { cout<<"six"; i--; break; } case 7: { cout<<"seven"; i--; break; } case 8: { cout<<"eight"; i--; break; } case 9: { cout<<"nine"; i--; break; } default: { i--; break; } } } else { i--; break; } } return 0; }
output:-