Perhaps you may take a look at this.. []
Code:
#include <stdio.h>
void convert(int n,char s[])
{
char *ones[]={"","One ","Two ","Three ","Four ","Five ","Six ","Seven ","Eight ","Nine ","Ten ","Eleven ","Twelve ","Thirteen ","Fourteen ","Fifteen ","Sixteen ","Seventeen ","Eighteen ","Nineteen "};
char *tens[]={"","","Twenty ","Thirty ","Forty ","Fifty ","Sixty ","Seventy ","Eighty ","Ninety "};
n>19 ? printf("%s%s%s",tens[n/10],ones[n%10],s):printf("%s%s",ones[n],s);
}
int main(void)
{
long n=111100077;
if(n>=10000000)
convert(n/10000000,"Crore ");
if((n%10000000)/100000)
convert((n%10000000)/100000,"Lakh ");
if((n%100000)/1000)
convert((n%100000)/1000,"Thousand ");
if((n%1000)/100)
convert((n%1000)/100,"Hundred ");
if(n%100)
convert(n%100,"");
return 0;
}
You need to put restriction since it wont work for more than 999999999. I hope you will be able to do it