Hello guys this is an amazing programming that converts entered digit into word.nut i need your help i am only able to do it upto 99.

#include<stdio.h>
#include<conio.h>
void main()
{
  int n,m,j;
  clrscr();
  printf("Enter any number between 1 to 99 : ");
  scanf("%d",&n);
  printf("You entered ");
  if(n>0&&n<=10)
     goto one;
  else if (n>10&&n<20)
       {
      m=n%10;
      goto two;
       }
       else if(n>20&&n<100)
        {
           j=n/10;
           n=n%10;
           goto three;
        }
 two:
 switch(m)
{
 case 1:printf("eleven ");
        break;
 case 2:printf("twelve ");
        break;
 case 3:printf("thirteen ");
        break;
 case 4:printf("fourteen ");
        break;
 case 5:printf("fifteen ");
        break;
 case 6:printf("sixteen ");
        break;
 case 7:printf("seventeen ");
        break;
 case 8:printf("eighteen ");
        break;
 case 9:printf("nineteen ");
        break;
}
 three:
 switch(j)
{
 case 2:printf("twenty ");
        goto one;
 case 3:printf("thirty ");
        goto one;
 case 4:printf("fourty ");
        goto one;
 case 5:printf("fifty ");
        goto one;
 case 6:printf("sixty ");
        goto one;
 case 7:printf("seventy ");
        goto one;
 case 8:printf("eighty ");
        goto one;
 case 9:printf("ninety ");
        goto one;
}
 one:
 switch(n)
{
 case 1:printf("one ");
        break;
 case 2:printf("two ");
        break;
 case 3:printf("three ");
        break;
 case 4:printf("four ");
        break;
 case 5:printf("five ");
        break;
 case 6:printf("six ");
        break;
 case 7:printf("seven ");
        break;
 case 8:printf("eight ");
        break;
 case 9:printf("nine ");
        break;
 case 10:printf("ten ");
        break;
}
getch();
}

Hello guys this is an amazing programming that converts entered digit into word.nut i need your help i am only able to do it upto 99.

#include<stdio.h>
#include<conio.h>
void main()
{
int n,m,j;
clrscr();
printf("Enter any number between 1 to 99 : ");
scanf("%d",&n);
printf("You entered ");
if(n>0&&n<=10)
goto one;
else if (n>10&&n<20)
{
m=n%10;
goto two;
}
else if(n>20&&n<100)
{
j=n/10;
n=n%10;
goto three;
}
two:
switch(m)
{
case 1:printf("eleven ");
break;
case 2:printf("twelve ");
break;
case 3:printf("thirteen ");
break;
case 4:printf("fourteen ");
break;
case 5:printf("fifteen ");
break;
case 6:printf("sixteen ");
break;
case 7:printf("seventeen ");
break;
case 8:printf("eighteen ");
break;
case 9:printf("nineteen ");
break;
}
three:
switch(j)
{
case 2:printf("twenty ");
goto one;
case 3:printf("thirty ");
goto one;
case 4:printf("fourty ");
goto one;
case 5:printf("fifty ");
goto one;
case 6:printf("sixty ");
goto one;
case 7:printf("seventy ");
goto one;
case 8:printf("eighty ");
goto one;
case 9:printf("ninety ");
goto one;
}
one:
switch(n)
{
case 1:printf("one ");
break;
case 2:printf("two ");
break;
case 3:printf("three ");
break;
case 4:printf("four ");
break;
case 5:printf("five ");
break;
case 6:printf("six ");
break;
case 7:printf("seven ");
break;
case 8:printf("eight ");
break;
case 9:printf("nine ");
break;
case 10:printf("ten ");
break;
}
getch();
}

/*
   * Number to Words
   * Sreejith M M
*/

#include <stdio.h>
#include <string.h>
#include <stdlib.h>

char *numberArray[] = {" Zero", " One", " Two", " Three", " Four", " Five", " Six", " Seven", " Eight", " Nine", " Ten", " Eleven", " Twelve", " Thirteen", " Fourteen", " Fifteen"," Sixteen", " Seventeen", " Eighteen", "Nineteen"};


char *tensArray[] = {"",""," Twenty"," Thirty", " Forty", " Fifty", " Sixty", " Seventy", " Eighty", " Ninety"};

char *middNames[] = {""," Thousand"," Million"," Billion"};

char* Numbertowords(int temp)
{

        /*Initialize a string */
        char *textToTransfer;

        int hund_,ten_,unit_,saved_tens;

        /* I expect maximum 100 characters per 3 digits as of now.Try to make it dynamic */
        textToTransfer = (char*)calloc(1,100);

        hund_ = temp / 100;
        ten_ = temp % 100;
        saved_tens = ten_;
        if (hund_)
        {

                printf("%d->%s()::%s\n",__LINE__,__func__,textToTransfer);
                strcat(textToTransfer,numberArray[hund_]);
                strcat(textToTransfer," hundred");
                printf("%d->%s()::%s\n",__LINE__,__func__,textToTransfer);


                if (ten_)
                {
                        printf("%d->%s()::%s\n",__LINE__,__func__,textToTransfer);
                        strcat(textToTransfer," and");
                }
        }
        ten_ = ten_ / 10;
        unit_ = saved_tens % 10;

        if (ten_ > 1)
        {
                               printf("%d->%s()::%s\n",__LINE__,__func__,textToTransfer);
                strcat(textToTransfer,tensArray[ten_]);
                if (unit_)
                {
                        printf("%d->%s()::%s\n",__LINE__,__func__,textToTransfer);
                        strcat(textToTransfer,numberArray[unit_]);
                }
        }
        else if(saved_tens != 0)
        {
                printf("%d->%s()::%s\n",__LINE__,__func__,textToTransfer);
                strcat(textToTransfer,numberArray[saved_tens]);
        }
        printf("%d->%s()::%s\n",__LINE__,__func__,textToTransfer);
        return (textToTransfer);
}


int main()
{
        int number,dummy;
        char neg_flag = 0;
        char *strings[10];
        int i,j;

        char fullstring[150] = {'\0'}; /* try to make it dynamic */
        number = 0;
        printf("\nEnter the number you want to convert to words:->");
        scanf("%d",&number);
        if ( 0 > number)
                neg_flag = 1;

        /* store in a dummy variable */
        dummy = number;

        /* Conditions starts */
        if (0 == number)
        {
                printf("\nZero");
                exit(0);
        }
        else
        {
               /* Convert to three digits groups */
                /* a 7 Digit number contains only 3 3digit groups*/
                for (i=0; ((i <= 2) && (dummy != 0));i++)
                {
                        strings[i] = Numbertowords(dummy % 1000);
                        dummy /= 1000;
                        printf("i = %d Dummy = %d\n",i,dummy);
                }
                j = i;
                /* First print the strings */
                for(i = 0;i < j;i++)
                {
                        printf("%s\t",strings[i]);
                }
        }
        /* Now we have the strings in the strings[i] array */
        for (i = (j-1); i >=0; i--)
        {
                strcat(fullstring,strings[i]);
                strcat(fullstring,middNames[i]);
        }
        printf("\n*********************************\n");
        printf("\n Your input : %d\n",number);
        printf("\n Mystring : ");
        if (neg_flag != 0)
                printf("Negative");
        printf(" %s",fullstring);
        printf("\n*********************************\n");

        return 0;
}

Try this

Thanks all for the info i was not knowing and the program

//This code will works upto 9999 u can try...
#include<stdio.h>
#include<conio.h>
int temp,temp1,temp2,flag;
int abovetwnty(int rev)
{
	    if(rev==1)
	    aboveten(rev);
       else if(rev==2)
	printf("Twenty");
	else if(rev==3)
	printf("Thirty");
	else if(rev==4)
	printf("Fourty");
	else if(rev==5)
	printf("Fifty");
	else if(rev==6)
	printf("Sixty");
	else if(rev==7)
	printf("Seventy");
	else if(rev==8)
	printf("Eighty");
	else if(rev==9)
	printf("Ninety");
	return;
}
int aboveten(int rev)
{       if(rev==10)
printf("Ten");
	else if(rev==11)
	printf("Eleven");
	else if(rev==12)
	printf("Twelvel");
	else if(rev==13)
	printf("Thirteen");
	else if(rev==14)
	printf("Fourteen");
	else if(rev==15)
	printf("Fifteen");
	else if(rev==16)
	printf("Sixteen");
	else if(rev==17)
	printf("Seventeen");
	else if(rev==18)
	printf("Eighteen");
	else if(rev==19)
	printf("Nineteen");
 return;
}
int swith(unsigned int rev)
{
	if(rev==1)
	printf("One");

	else if(rev==2)
	printf("Two");
	else if(rev==3)
	printf("Three");
	else if(rev==4)
	printf("Four");
	else if(rev==5)
	printf("Five");
	else if(rev==6)
	printf("Six");
	else if(rev==7)
	printf("Seven");
	else if(rev==8)
	printf("Eight");
	else if(rev==9)
	printf("Nine");
	return;
}
void expansion(unsigned int rev,int count)
{
    if(count==4)
    printf("Thousand ",swith(rev));
    else if(count==3&&rev!=0)
    printf("Hundreed",swith(rev));
    else if(count==2)
    {
    temp1=temp%100;
    if(temp1>=10&&temp1<=19)
    {
    aboveten(temp1);
    flag=1;
    }
    else
    abovetwnty(rev);
    }
     if(flag!=1 && count==1)
     swith(rev);
}



void rev(unsigned int n)
{
unsigned int y,digit=0,rev=0;
int count=0;

while(n!=0)
{
	digit=n%10;
	rev=rev*10+ digit;
	n=n/10;
	count++;
}

while(rev!=0)
	{
	digit=rev%10;
	rev=rev/10;
	expansion(digit,count);
	count--;
	}
	
}


void main()
{
unsigned int n;
clrscr();
printf("Enter the no\n");
scanf("%u",&n);
temp2=temp=n;
if(n==0)
printf("Zero");

else if(n>=10 && n<20)
aboveten(n);
else
rev(n);
getch();
}

Use CODE Tags!!!

Do you have a question or do you just want us to test it for you?

Converts any number to its corresponding word form (valid upto 9 digits)

#include<stdio.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"};


void main()
{
 long n;
 clrscr();
 printf("Enter any 9 digit no.(or less) : ");
 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)," ");
 }
 getch();
}


void pw(long n,char ch[])
{
 (n>19)?printf("%s %s ",ten[n/10],one[n%10]):printf("%s ",one[n]);
 if(n)printf("%s ",ch);
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.