Code:#include<iostream> #include<string> using namespace std; string text(int c); string numInWords(int num); int main() { int num;cout<<"enter the number : ";cin>>num; cout<<"In words :\n"<<numInWords(num)<<endl; return 0; } string numInWords(int num) { double a=num; int c1=0,c2=0,c3=0; int c4; if(a>=1000000000) { a/=1000000000; c1=a;a=(a-c1)*1000000000; } if(a>=1000000) { a/=1000000; c2=a;a=(a-c2)*1000000; } if(a>=1000) { a/=1000; c3=a;a=(a-c3)*1000; } c4=a; string s1=text(c1);string s2=text(c2);string s3=text(c3);string s4=text(c4); string m1="",m2="",m3="",temp=""; if(s1!=temp)m1=" billion ";if(s2!=temp)m2=" million ";if(s3!=temp)m3=" thousand "; return s1+m1+s2+m2+s3+m3+s4; } string text(int c) { string h="",t="",o=""; bool odd=false; if(c>=900) h="nine hundred "; else if(c>=800) h="eight hundred "; else if(c>=700) h="seven hundred "; else if(c>=600) h="six hundred "; else if(c>=500) h="five hundred "; else if(c>=400) h="four hundred "; else if(c>=300) h="three hundred "; else if(c>=200) h="two hundred "; else if(c>=100) h="one hundred "; else{} double tens=c/100.0;tens=(tens-(int)(tens))*100; if(tens>=90) t="ninety "; else if(tens>=80) t="eighty "; else if(tens>=70) t="seventy "; else if(tens>=60) t="sixty "; else if(tens>=50) t="fifty "; else if(tens>=40) t="forty "; else if(tens>=30) t="thirty "; else if(tens>=20) t="twenty "; else if(tens==19){ t="nineteen";odd=true; } else if(tens==18){ t="eighteen";odd=true; } else if(tens==17){ t="seventeen";odd=true; } else if(tens==16){ t="sixteen";odd=true; } else if(tens==15){ t="fifteen";odd=true; } else if(tens==14){ t="fourteen";odd=true; } else if(tens==13){ t="thirteen";odd=true; } else if(tens==12){ t="twelve";odd=true; } else if(tens==11){ t="eleven";odd=true; } else if(tens==10){ t="ten";odd=true; } else{} if(!odd){ tens/=10;tens=(tens-(int)(tens))*10; if(tens==9)o="nine"; if(tens==8)o="eight"; if(tens==7)o="seven"; if(tens==6)o="six"; if(tens==5)o="five"; if(tens==4)o="four"; if(tens==3)o="three"; if(tens==2)o="two"; if(tens==1)o="one"; } return h+t+o; }