Program To Convert Number In Word To Digit In C Language

#include  stdio.h        // friend's  this blog page considering this including file as html tags so why
#include  conio.h     // I removed brackets.
#include  string.h
#include  math.h
void main()
{
    char no[70];
    char *st;
    int i,m=0,j,k,l,n,p,q;
        char *a[50][50]={{"Zero","","","","","","","","",},{"One","Ten","One Hundred","One Thousand","Ten Thousand","One Lakh","Ten Lakh","One Crore","Ten Crore"},
                     {"Two","Twenty","Two Hundred","Two Thousand","Twenty Thousand","Two Lakh","Twenty Lakh","Two Crore","Twenty Crore"},
                     {"Three","Thirty","Three Hundred","Three Thousand","Thirty Thousand","Three Lakh","Thirty Lakh","Three Crore","Thirty Crore"},
                     {"Four","Fourty","Four Hundred","Four Thousand","Foutry Thousand","Four Lakh","Fourty Lakh","Four Crore","Fourty Crore"},
                     {"Five","Fifty","Five Hundred","Five Thousand","Fifty Thousand","Five Lakh","Fifty Lakh","Five Crore","Fifty Crore"},
                     {"Six","Sixty","Six Hundred","Six Thousand","Sixty Thousand","Six Lakh","Sixty Lakh","Six Crore","Sixty Crore"},
                     {"Seven","Seventy","Seven Hundred","Seven Thousand","Seventy Thousand","Seven Lakh","Seventy Lakh","Seven Crore","Seventy Crore"},
                     {"Eight","Eighty","Eight Hundred","Eight Thousand","Eighty Thousand","Eight Lakh","Eighty Lakh","Eight Crore","Eight Crore"},
                     {"Nine","Ninty","Nine Hundred","Nine Thousand","Ninty Thousand","Nine Lakh","Ninty Lakh","Nine Crore","Ninty Crore"}};
    char *b[15][10]={{"","","","","","","","",""},
                    {"Eleven","","","Eleven Thousand","","Eleven Lakh","","Eleven Crore"},
                    {"Twelve","","","Twelve Thousand","","Twelve Lakh","","Twelve Crore"},                                          {"Thirteen","","","Thirteen Thousand","","Thirteen Lakh","","Thirteen Crore"},
                    {"Fourteen","","","Fourteen Thousand","","Fourteen Lakh","","Fourteen Crore"},
                    {"Fifteen","","","Fifteen Thousand","","Fifteen Lakh","","Fifteen Crore"},
                    {"Sixteen","","","Sixteen Thousand","","Sixteen Lakh","","Sixteen Crore"},
                    {"Seventeen","","","Seventeen Thousand","","Seventeen Lakh","","Seventeen Crore"},
                    {"Eighteen","","","Eighteen Thousand","","Eighteen Lakh","","Eighteen Crore"},
                    {"Ninteen","","","Ninteen Thousand","","Ninteen Lakh","","Ninteen Crore"}};
    printf("Enter Your Number In Word=");
      gets(no);
     st=strtok(no,",");
     while (st!= NULL)
     {
         for(i=0;i<10 br="" i="">        {
            for(j=0;j<9 br="" j="">            {
                k=strcmpi(a[i][j],st);
                if(k==0)
                   {
                    m=m+i*pow(10,j);
                }
                else
                {
                    l=strcmpi(b[i][j],st);   
                    if(l==0)
                    {
                        q=j;
                        q=q+1;
                        p=pow(10,q)+i*pow(10,j);
                        m=m+p;
                    }       
                }       
            }   
        }
     st=strtok (NULL,",");
    }
    printf("%d",m);
}
/*output:-
Enter Your Number In Word=ten crore,seventy lakh,fifty thousand,eight hundred,sixty,nine -----PLEASE GIVE INPUT LIKE THIS. "," IN NECESSARY AT RIGHT POSITION.
Ans=107050869
*/

Comments

Unknown said…
There is a error in this line saying ";" is not present
for(i=0;i<10 br="" i=""> {
for(j=0;j<9 br="" j=""> {
when i put ";" in between the br="" it is saying can't convert char to int. and also br is not declared in the main

Popular posts from this blog

Program To Convert Digit To Word.

Program To Convert Upto 9 Digit Number To Words