C program to convert amount to words

/* Write a C Program to convert the digits to word*/
#include<stdio.h>
#include<conio.h>
void pw(long,char[]);
char *one[]={" "," one"," two"," three"," four"," five"," six"," seven","eight"," Nine"," ten"," eleven"," twelve"," thirteen"," fourteen","fifteen"," sixteen"," seventeen"," eighteen"," nineteen"};
char *ten[]={" "," "," twenty"," thirty"," forty"," fifty"," sixty","seventy"," eighty"," ninety"};
int main()
{
long n;
clrscr();
printf("Enter any 9 digit no: ");
scanf("%9ld",&n);
                 if(n<=0)
                printf("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)," ");
}
                 return 0;

}


Output
---------
Enter numbers grater than 0
234
2 hundred and thirty four

No comments: