You are on page 1of 1

// Prg 2 Convert Numbers into Words

// A Prg by Sukhdev Singh


// pw is short 4 print word,pw is fxn 2 convert nos in words
#include<iostream.h>
#include<conio.h>
void pw(long,char[]);
char *one[]={" "," one"," two"," three"}; // upto 19
char *ten[]={" "," "," twenty"," thirty"};//upto 90
void main()
{
long n; clrscr();
cout<< "Enter any 9 digit no: ";
cin>>n;
if(n<=0) cout << "Enter numbers greater than 0";
else {
pw((n/10000000),"crore");
pw(((n/100000)%100),"lakh");
pw(((n/1000)%100),"thousand");
pw(((n/100)%10),"hundred");
pw((n%100)," ");
}
getch();
}
void pw(long n,char ch[])
{
(n>19)?cout <<" "<<ten[n/10]<<" "<< one[n%10]:cout <<" "<<one[n]; // spaces are
deliberately for better output
if(n)cout <<" "<<ch; // watch 4 space
}

You might also like