# Write a program to convert numbers into words?For ex: 547,as Five Hundred and Forty Seven

Showing Answers 1 - 18 of 18 Answers

#### kamatchi

• Nov 6th, 2006

```Code
void main()
{
char a[10][10]={"ONE","TWO","THREE","FOUR","FIVE","SIX","SEVEN","EIGHT","NINE"};
char b[10][10]={"ELEVEN","TWELVE","THIRTEEN","FOURTEEN","FIFTEEN","SIXTEEN",
"SEVENTEEN","EIGHTEEN","NINTEEN"};
char c[10][10]={"TEN","TWENTY","THIRTY","FOURTY","FIFTY","SIXTY","SEVENTY",
"EIGHTY","NINTY"};
int no,t;
clrscr();
printf("ttEnter the number");
scanf("%d",&no);
printf("tt");
if(no<9999)
{
if(no>1000)
{
t=no/1000;
no=no%1000;
printf("%s THOUSAND",a[t-1]);
}
if(no>100)
{
t=no/100;
no=no%100;
printf(" %s HUNDRED AND ",a[t-1]);
}
if(no>=10 && no<20)
{
t=no/10;
printf(" %s",b[t-1]);
}
if(no>19 && no<=100)
{
t=no/10;
no=no%10;
printf("%s",c[t-1]);
}
if(no<10)
{
printf(" %s",a[no-1]);
}
}
else
printf("ttEnter the small number");
getch();
}
```

#### Sundar A

• Nov 29th, 2006

Gud idea!!! But how will "1003" Work???

#### abhimanipal Profile Answers by abhimanipal

• Jul 16th, 2009

This is not a final answer ...More an algorithm

Suppose we will consider numbers till 9,999 only ...

Array1 --> One,two,three,four,five ......nine
Array2 --> Eleven, Twelve,thirteen,Fourteen.....Nineteen
Array3 --> Twenty,Thirty,Forty,Fifty,Sixty......Ninety
Array4 --> One hundred,two hundred,three hundred,four hundred..... nine hundred
Array5 --> One thousand, two thousand, three thousand .... nine thousand

First check if the number is between 11-20
If yes then print the number
If no then print the last digit from array1 and second last digit from array3.
Similary print the digit in the hundred place from Array 4
Then print the digit in thousands place from Array5

For going beyond this we again use the above technique only....
Also this algorithm prints out the digits in reverse. So to print correct insert in reverse in a linked list. So when the list prints it will print straight.

#### sivaraju.sateesh Profile Answers by sivaraju.sateesh

• Jul 19th, 2010

```Code#include<stdio.h>
main()
{
int n,temp,rev=0;
scanf("%d",&n);
temp=n;
while(n>0)
{
rev=(rev*10)+(n%10);
n=n/10;
}
printf("%d",rev);
while(rev>0)
{
switch(rev%10)
{
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 0:printf("zero ");
break;
}
rev=rev/10;
}
while(temp%10==0)
{
printf("zero ");
temp=temp/10;
}```

#### Sameer Habib Khan

• Dec 17th, 2012

Here is Better code that converts number (upto 9 digit) to word

```Code/*
Author: Sameer Khan
Date:   17/12/2012
Program:Number to Word Convertor

*/

import java.io.*;
import java.util.*;

public class NumberToWord
{

static String word="";
public static void main(String...args) throws IOException
{

String response="";
do{

System.out.println("
Enter A Number(Upto 9 Digit): ");

Convert(input);
System.out.println("
Word: "+word);

word="";//reset

System.out.println("
Do You Want to Continue..?(y/n)");

}while(response.equalsIgnoreCase("y"));

}

public static void Convert(String input)
{

int number=Integer.parseInt(input);
if(number==0)
{
word="Zero";
return;
}
int d=0;

int len=input.length(); // Get total digits in number
switch(len)
{
case 1:
ones(number);
break;
case 2:
twos(number);
break;
case 3:
threes(number);
break;
case 4:
fours(number);
break;
case 5:
fives(number);
break;
case 6:
sixs(number);
break;
case 7:
sevens(number);
break;
case 8:
eights(number);
break;
case 9:
nines(number);
break;

}

}

public static void ones(int c)
{
switch(c)
{
case 1: word+="One";
break;
case 2: word+="Two";
break;
case 3:word+="Three";
break;
case 4:word+="Four";
break;
case 5:word+="Five";
break;
case 6:word+="Six";
break;
case 7:word+="Seven";
break;
case 8:word+="Eight";
break;
case 9:word+="Nine";
break;
}

}

public static void twos(int c)
{
if(c>9&&c<20)
{
switch(c)
{

case 10: word+="Ten";
break;
case 11: word+="Eleven";
break;
case 12: word+="Twelve";
break;
case 13:word+="Thirteen";
break;
case 14:word+="Fourteen";
break;
case 15:word+="Fifteen";
break;
case 16:word+="Sixteen";
break;
case 17:word+="Seventeen";
break;
case 18:word+="Eightteen";
break;
case 19:word+="Nineteen";
break;

}

}
else
{

if(c>=20&&c<30)
{
word=word+"Twenty ";
ones(c%10);

}
if(c>=30&&c<40)
{
word=word+"Thirty ";
ones(c%10);

}
if(c>=40&&c<50)
{
word=word+"Fourty ";
ones(c%10);

}
if(c>=50&&c<60)
{
word=word+"Fifty ";
ones(c%10);

}
if(c>=60&&c<70)
{
word=word+"Sixty ";
ones(c%10);

}
if(c>=70&&c<80)
{
word=word+"Seventy ";
ones(c%10);

}
if(c>=80&&c<90)
{
word=word+"Eighty ";
ones(c%10);

}
if(c>=90&&c<100)
{
word=word+"Ninety ";
ones(c%10);

}

}

}

public static void threes(int c)
{
if(c!=0)
{
ones(c/100);
word=word+" Hundred ";
twos(c%100);
}
}

public static void fours(int c)
{

ones(c/1000);
c=c%1000;
word=word+" Thousand ";
threes(c%1000);

}

public static void fives(int c)
{
twos(c/1000);
fours(c%1000);

}

public static void sixs(int c)
{
ones(c/100000);
word=word+" Lakh ";
if((c%100000)!=0)
fives(c%100000);

}

public static void sevens(int c)
{
twos(c/100000);
word=word+" Lakhs ";
if((c%100000)!=0)
fives(c%100000);
}

public static void eights(int c)
{
ones(c/10000000);
word=word+" Crore ";
if((c%100000)!=0)
sevens(c%10000000);

}

public static void nines(int c)
{
twos(c/10000000);
word=word+" Crores ";
if((c%100000)!=0)
sevens(c%10000000);

}

}```

#### mm

• Apr 22nd, 2013

```Code#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)," ");
}
//getch();
return 0;
}
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);
}```

```Code#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)," ");
}
//getch();
return 0;
}

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);
}
```

#### jbode Profile Answers by jbode Questions by jbode

• Apr 24th, 2013

The following handles up to 32-bit integer values. Not the prettiest code in the world, but it works pretty well.

Sample output:

[fbgo448@n9dvap997]~/prototypes/numbers: ./numbers 1

one

[fbgo448@n9dvap997]~/prototypes/numbers: ./numbers 12

twelve

[fbgo448@n9dvap997]~/prototypes/numbers: ./numbers 123

one hundred and twenty-three

[fbgo448@n9dvap997]~/prototypes/numbers: ./numbers 1234

one thousand, two hundred and thirty-four

[fbgo448@n9dvap997]~/prototypes/numbers: ./numbers 12345

twelve thousand, three hundred and forty-five

[fbgo448@n9dvap997]~/prototypes/numbers: ./numbers 123456

one hundred and twenty-three thousand, four hundred and fifty-six

[fbgo448@n9dvap997]~/prototypes/numbers: ./numbers 1234567

one million, two hundred and thirty-four thousand, five hundred and sixty-seven

[fbgo448@n9dvap997]~/prototypes/numbers: ./numbers -1234567890

minus one billion, two hundred and thirty-four million, five hundred and sixty-seven thousand, eight hundred and ninety

```Code#include <stdio.h>
#include <stdlib.h>
#include <math.h>

static char *units[] = {
"", "one", "two", "three", "four",
"five", "six", "seven", "eight", "nine"
};

static char *teens[] = {
"ten", "eleven", "twelve", "thirteen", "fourteen",
"fifteen", "sixteen", "seventeen", "eighteen", "nineteen"
};

static char *decades[] = {
"", "", "twenty", "thirty", "forty", "fifty", "sixty",
"seventy", "eighty", "ninety"
};

static char *magnitudes[] = {
"", "thousand", "million", "billion"
};

/**
* Return the total number of digits in the value
*/
int getDigits( long val )
{
return (int) (floor( log10( (double) abs( val )))) + 1;
}

/**
* Print each century, a group of up to 3 digits
*
*    1  => one
*   12  => twelve
*  123  => one hundred twenty-three
*/
void printCentury( int val )
{
char *join = "";
if ( val > 99 )
{
int cent = val / 100;
printf( "%s hundred ", units[cent] );
val -= cent * 100;
if ( val > 0 )
join = "and ";
}

if ( val > 19 )
{
printf( "%s%s", join, decades[val / 10] );
if ( val % 10 > 0 )
printf( "-%s ", units[val % 10] );
else
putchar(   );
}
else if ( val >= 10 )
{
printf( "%s%s ", join, teens[val % 10] );
}
else if ( val > 0 )
{
printf( "%s%s ", join, units[val] );
}
}

int main( int argc, char **argv )
{
long val = 0;

if ( argc > 1 )
{
val = strtol( argv[1], NULL, 10 );
}
else
{
fprintf( stderr, "USAGE: %s <number>\n", argv[0] );
return 0;
}

if ( val < 0 )
{
printf( "minus " );
val = -val;
}

if ( val == 0 )
printf( "zero" );
else
{
/**
* Break value into groups of hundreds,
* such as:
*
*       12 =         12
*      123 =>       123
*     1234 =>     1 234
*    12345 =>    12 345
*   123456 =>   123 456
*  1234567 => 1 234 567
*
* and print each group with the proper
* magnitude (one million, two hundred and thirty-four
* thousand, five hundred and sixty-seven for the last
* example)
*/
char *sep = "";
while ( val > 100L )
{
int digits = getDigits( val );
int mag = (digits - 1) / 3;
long order = (long) ( pow (10.0, 3 * mag ));
long cent = val / order;
printf( "%s", sep );
sep = ", ";
printCentury( (int) cent );
printf( "%s", magnitudes[mag] );
val -= cent * order;
}
if ( val > 0 && sep != "" )
printf( " and " );
printCentury( val );
}
putchar(\n);
return 0;
}
```

#### khalid

• May 10th, 2014

Accept a number from user and display the hundred, teen 9 units in value

#### Chahit

• Jun 12th, 2014

The correct code is following (it works for till user enters max value for int i.e. 2,147,483,647)

```Code/*
* Program to convert entered number into string
* */

package com.orkash.assignment3;

import java.util.Scanner;

public class NumberToWords {
public static void main(String[] args)
{
double num;//for taking input number
Scanner obj=new Scanner(System.in);
do
{
System.out.println("

Enter the Number (Maximum value that can be entered is 2,147,483,647)");
num=obj.nextDouble();
if(num<=2147483647)//checking if entered number exceeds maximum integer value
{
int number=(int)num;//type casting double number to integer number
splitNumber(number);//calling splitNumber-it will split complete number in pairs of 3 digits
}
else
System.out.println("Enter smaller value");//asking user to enter a smaller value compared to 2,147,483,647
}while(num>2147483647);
}
//function to split complete number into pair of 3 digits each
public static void splitNumber(int number)
{       //splitNumber array-contains the numbers in pair of 3 digits
int splitNumber[]=new int[4],temp=number,i=0,index;
//splitting number into pair of 3
if(temp==0)
System.out.println("zero");
while(temp!=0)
{
splitNumber[i++]=temp%1000;
temp/=1000;
}
//passing each pair of 3 digits to another function
for(int j=i-1;j>-1;j--)
{       //toWords function will split pair of 3 digits to separate digits
if(splitNumber[j]!=0)
{toWords(splitNumber[j]);
if(j==3)//if the number contained more than 9 digits
System.out.print("billion,");
else if(j==2)//if the number contained more than 6 digits & less than 10 digits
System.out.print("million,");
else if(j==1)
System.out.print("thousand,");//if the number contained more than 3 digits & less than 7 digits
}
}
}
//function that splits number into individual digits
public static void toWords(int number)
//splitSmallNumber array contains individual digits of number passed to this function
{       int splitSmallNumber[]=new int[3],i=0,j;
int temp=number;//making temporary copy of the number
//logic to split number into its constituent digits

while(temp!=0)
{
splitSmallNumber[i++]=temp%10;
temp/=10;
}
//printing words for each digit
for(j=i-1;j>-1;j--)
//{   if the digit is greater than zero
if(splitSmallNumber[j]>=0)
//if the digit is at 3rd place or if digit is at (1st place with digit at 2nd place not equal to zero)
{       if(j==2||(j==0 && (splitSmallNumber[1]!=1)))
{
switch(splitSmallNumber[j])
{

case 1:System.out.print("one ");break;
case 2:System.out.print("two ");break;
case 3:System.out.print("three ");break;
case 4:System.out.print("four ");break;
case 5:System.out.print("five ");break;
case 6:System.out.print("six ");break;
case 7:System.out.print("seven ");break;
case 8:System.out.print("eight ");break;
case 9:System.out.print("nine ");break;

}

}
//if digit is at 2nd place
if(j==1)
{               //if digit at 2nd place is 0 or 1
if(((splitSmallNumber[j]==0)||(splitSmallNumber[j]==1))&& splitSmallNumber[2]!=0 )
System.out.print("hundred ");
switch(splitSmallNumber[1])
{       case 1://if digit at 2nd place is 1 example-213
switch(splitSmallNumber[0])
{
case 1:System.out.print("eleven ");break;
case 2:System.out.print("twelve ");break;
case 3:System.out.print("thirteen ");break;
case 4:System.out.print("fourteen ");break;
case 5:System.out.print("fifteen ");break;
case 6:System.out.print("sixteen ");break;
case 7:System.out.print("seventeen ");break;
case 8:System.out.print("eighteen ");break;
case 9:System.out.print("nineteen ");break;
case 0:System.out.print("ten ");break;
}break;
//if digit at 2nd place is not 1
case 2:System.out.print("twenty ");break;
case 3:System.out.print("thirty ");break;
case 4:System.out.print("forty ");break;
case 5:System.out.print("fifty ");break;
case 6:System.out.print("sixty ");break;
case 7:System.out.print("seventy ");break;
case 8:System.out.print("eighty ");break;
case 9:System.out.print("ninety ");break;
//case 0:       System.out.println("hundred ");break;

}
}
}
}

}```

#### Shridhar

• Jun 27th, 2014

```Code#include<stdio.h>
main() {        int n,u,t,h,th;
jamkhandi: printf("enter a 4 digit non negative number  ");
scanf("%d",&n);
if(n<0) goto jamkhandi;
printf(" the entered number is :-  ");
if(n==0)printf("zero ");
else {
u=n%10;
n=n-u;
t=n%100; t=t/10;
h=n%1000;
h=h/100;
th=n%10000; th=th/1000;         }
switch(th)    {         case 1: {
char th1[100]="one thousand";
printf("%s ",th1);break;             }
case 2: {
char th1[100]="two thousand";
printf("%s ",th1);break;             }
case 3: {
char th1[100]="three thousand";
printf("%s ",th1);break;             }
case 4: {
char th1[100]="four thousand";
printf("%s ",th1);break;             }
case 5: {
char th1[100]="five thousand";
printf("%s ",th1);break;             }
case 6: {
char th1[100]="six thousand";
printf("%s ",th1);break;             }
case 7: {
char th1[100]="seven thousand";
printf("%s ",th1);break;             }
case 8: {
char th1[100]="eight thousand";
printf("%s ",th1);break;             }
case 9: {
char th1[100]="nine thousand";
printf("%s ",th1);break;             }    }
switch(h)    {          case 1: {
char h1[100]="one hundred";
printf("%s ",h1);break;             }
case 2: {
char h1[100]="two hundred";
printf("%s ",h1);break;             }
case 3: {
char h1[100]="three hundred";
printf("%s ",h1);break;             }
case 4: {
char h1[100]="four hundred";
printf("%s ",h1);break;             }
case 5: {
char h1[100]="five hundred";
printf("%s ",h1);break;             }
case 6: {
char h1[100]="six hundred";
printf("%s ",h1);break;             }
case 7: {                  char h1[100]="seven hundred";
printf("%s ",h1);break;             }
case 8: {                  char h1[100]="eight hundred";
printf("%s ",h1);break;             }
case 9: {                  char h1[100]="nine hundred";
printf("%s ",h1);break;             }    }
switch(t)     {          case 1:
{ if(u==1)              {
char t1[100]={e,l,e,v,e,n,};
printf("%s",t1);
break;         }
if(u==2)                {
char t1[100]={t,w,e,l,v,e,};
printf("%s",t1);       break;         }
if(u==3)                  {
char t1[100]={t,h,i,r,t,e,e,n,};
printf("%s",t1);
break;
}         if(u==4)
{
char t1[100]={f,o,u,r,t,e,e,n,};
printf("%s",t1);
break;         }
if(u==5)              {
char t1[100]={f,i,f,t,e,e,n,};
printf("%s",t1);
break;
}
if(u==6)
{
char t1[100]={s,i,x,t,e,e,n,};
printf("%s",t1);
break;         }
if(u==7)            {
char t1[100]={s,e,v,e,n,t,e,e,n,};
printf("%s",t1);       break;         }
if(u==8)            {
char t1[100]={e,i,g,h,t,e,e,n,};
printf("%s",t1);       break;         }
if(u==9)               {
char t1[100]={n,i,n,t,e,e,n,};
printf("%s",t1);
break;         }         if(u==0)
{
char t1[100]={t,e,n,};
puts(t1);
break;      }            }
case 2: {
char t1[100]={t,w,e,n,t,y,};
printf("%s ",t1);
break;           }
case 3: {
char t1[100]={t,h,i,r,t,y,};
printf("%s ",t1);
break;           }
case 4: {
char t1[100]={f,o,r,t,y,};
printf("%s ",t1);
break;           }
case 5: {
char t1[100]={f,i,f,t,y,};
printf("%s ",t1);
break;
}
case 6: {
char t1[100]={s,i,x,t,y,};
printf("%s ",t1);
break;           }
case 7: {
char t1[100]={s,e,v,e,n,t,y,};
printf("%s ",t1);
break;           }

case 8: {
char t1[100]={e,i,g,h,t,y,};
printf("%s ",t1);
break;           }

case 9: {
char t1[100]={n,i,n,e,t,y,};
printf("%s ",t1);
break;           }                 }
if(t!=1)    {
switch(u)    {
case  1: {
char u1[100]={o,n,e,};
puts(u1);
break;                   }
case 2:  {
char u1[100]={t,w,o,};
puts(u1);
break;                  }
case 3:
{         char u1[100]={t,h,r,e,e,};
puts(u1);
break;                 }
case 4:  {
char u1[100]={f,o,u,r,};
puts(u1);
break;
}                    case 5:  {
char u1[100]={f,i,v,e,};
puts(u1);
break;              }
case 6:  {         char u1[100]={s,i,x,};
puts(u1);
break;                   }
case 7:  {
char u1[100]={s,e,v,e,n,};
puts(u1);
break;               }
case 8:  {
char u1[100]={e,i,g,h,t,};
puts(u1);
break;                  }
case 9:  {
char u1[100]={n,i,n,e,};
puts(u1);
break;                   }       }    }
getch(); }
</stdio.h>```

#### daisy

• Sep 24th, 2014

enter ur no. at field
STDIN Input:

```Code#include <stdio.h>;

void main()
{char a[10][10]={"ONE","TWO","THREE","FOUR","FIVE","SIX","SEVEN","EIGHT","NINE"};
char b[10][10]={"ELEVEN","TWELVE","THIRTEEN","FOURTEEN","FIFTEEN","SIXTEEN","SEVENTEEN","EIGHTEEN","NINTEEN"};
char c[10][10]={"TEN","TWENTY","THIRTY","FOURTY","FIFTY","SIXTY","SEVENTY","EIGHTY","NINTY"};
int no,t;
printf("        Enter the number");
scanf("%d",&no);
printf("        ");
if(no<9999)
{ if(no>=1000)
{  t=no/1000;
no=no%1000;
printf("%s THOUSAND",a[t-1]); }
if(no>=100)
{  t=no/100;
no=no%100;
printf(" %s HUNDRED ",a[t-1]); }
if(no>=10 && no<20)
{  t=no/10;
printf(" %s",b[t-1]); }
if(no>19 && no<=100)
{  t=no/10;
no=no%10;
printf("%s",c[t-1]); }
if(no<10)
{  printf(" %s",a[no-1]); }
}
else
printf("      Enter the small number");
} ```

#### naresh sathivilli

• Oct 29th, 2014

Please find the answer in C++ language!
It supports more than one Crore.

```Code

//Naresh Sathivilli

#include<iostream>

using namespace std;
const char *Digits []      = {"Zero","One","Two","Three","Four","Five","Six","Seven","Eight","Nine"};
const char *BelowTwenty[]  = {"Eleven","Twelve","Thirteen","Fourteen","Fifteen","Sixteen","Seventeen","Eighteen","Nineteen"};
const char *BelowHundred[] = {"Ten","Twenty","Thirty","Fourty","Fifty","Sixty","Seventy","Eighty","Ninty","Hundred"};
const char *Thousand       = "Thousand";
const char *Hundred        = "Hundred";
const char *Lakh           = "Lakh";
const char *Lakhs          = "Lakhs";
const char *Crore          = "Crore";
const char *Crores         = "Crores";

void Convert(long number)
{
//cout<<"number entry="<<number<<endl;
if(number >= 10000000)
{
Convert(number / 10000000);
if((number /  10000000) > 1)
cout<<Crores<<" ";
else
cout<<Crore<<" ";

number =number %  10000000;
}
else if(number < 10000000 && number >= 100000)
{
Convert(number / 100000);
if((number /  100000) > 1)
cout<<Lakhs<<" ";
else
cout<<Lakh<<" ";

number =number %  100000;
}
else if(number < 100000 && number >= 1000)
{
Convert(number / 1000);
number =number %  1000;
cout<<Thousand<<" ";
}
else if(number < 1000 && number > 100)
{
Convert(number / 100);
number =number %  100;
cout<<Hundred<<" ";
}
else if(number < 10)
{
cout<<*(Digits+(number))<<" ";
return;
}
else if(number > 10 and number < 20)
{
cout<<*(BelowTwenty+(number-11))<<" ";
return;
}
else if(number <= 100)
{
cout<<*(BelowHundred+(number / 10)-1)<<" ";
if(number == 100) return;
number %= 10;
}
else
{
return;
}
//cout<<"
number exit="<<number<<endl;
if(number == 0) return;
Convert(number);
}

int main()
{

Convert(987654326);

}

```

#### Pallavi Mahajan Profile Answers by Pallavi Mahajan

• Jan 29th, 2015

```Code/***** C program to convert number from 0 to 9999 into word******/
#include<stdio.h>
#include<conio.h>
void main()
{
char a[10][10]={"one","two","three","four","five","six","seven","eight","nine"};
char b[10][10]={"eleven","twelve","thirteen","fourteen","fifteen","sixteen","seventeen","eighteen","ninteen"};
char c[10][10]={"ten","twenty","thirty","fourty","fifty","sixty","seventy","eighty","ninty"};
int num,temp;
clrscr();
printf("
Enter number:");
scanf("%d",&num);
printf("        num : %d",num);
if(num<=9999)
{
if(num>=1000)
{
temp=num/1000;
num=num%1000;
printf("%s Thousand",a[temp-1]);
}

if(num>=100)
{
temp=num/100;
num=num%100;
printf("%s Hundred and",a[temp-1]);
}

if(num>10 && num<20)
{
temp=num%10;
printf("%s ",b[temp-1]);
}

if(num>19 && num<=100)
{
temp=num/10;
num=num%10;
printf("%s ",c[temp-1]);
}
if(num==10)
{
printf("%s",c[0]);
}
if(num<10)
{
printf("%s",a[num-1]);
}
if(num==0)
{
printf("zero");
}
}
else
printf("
Enter small number");
getch();
}```

#### aston martin

• Oct 30th, 2015

Guys no one can do in normal bufferedreader?
or in string? so much of jigjag!

#### Narasimhaswamy challa

• Jun 6th, 2016

C code to covert each digits of a number in English word

Convert digits to words in c

```Code

#include<stdio.h>

int main(){

int number,i=0,j,digit;
char * word[1000];

printf("Enter any integer: ");
scanf("%d",&number);

while(number){

digit = number %10;
number = number /10;

switch(digit){
case 0: word[i++] = "zero"; break;
case 1: word[i++] = "one"; break;
case 2: word[i++] = "two"; break;
case 3: word[i++] = "three"; break;
case 4: word[i++] = "four"; break;
case 5: word[i++] = "five"; break;
case 6: word[i++] = "six"; break;
case 7: word[i++] = "seven"; break;
case 8: word[i++] = "eight"; break;
case 9: word[i++] = "nine"; break;

}
}

for(j=i-1;j>=0;j--){
printf("%s ",word[j]);
}

return 0;

}
```

Sample output:

Enter any integer: 23451208
two three four five one two zero eight

#### Shahriar Tasnim

• Apr 29th, 2017

```Code#include<iostream>
using namespace std;
int x,e,b;
void p(int n,int k,int o,int y);
void c(int k,int l)
{
if(k==0);
else if(k==1)
{
if(l==0)
cout<<"Ten ";
else if(l==1)
cout<<"Eleven ";
else if(l==2)
cout<<"Twelve ";
else if(l==3)
cout<<"Thirteen ";
else if(l==4)
cout<<"Fourteen ";
else if(l==5)
cout<<"Fifteen ";
else if(l==6)
cout<<"Sixteen ";
else if(l==7)
cout<<"Seventeen ";
else if(l==8)
cout<<"Eighteen ";
else if(l==9)
cout<<"Nineteen ";
}
else if(k==2)
cout<<"Twenty ";
else if(k==3)
cout<<"Thirty ";
else if(k==4)
cout<<"Forty ";
else if(k==5)
cout<<"Fifty ";
else if(k==6)
cout<<"Sixty ";
else if(k==7)
cout<<"Seventy ";
else if(k==8)
cout<<"Eighty ";
else if(k==9)
cout<<"Ninety ";
}
void ta(int n,int r,int q,int o,int u,int g)
{
if(g!=0)
{
if (n==0);
else if(n==1);
else if(n==2)
c(r,q);
else if(n==3)
cout<<"Hundred ";
else if(n==4)
cout<<"Thousand ";
else if(n==5)
c(o,u);
else if(n==6)
cout<<"Lac ";
else if(n==7)
cout<<"Million ";
else if(n==8)
cout<<"Crore ";
}
else if(g==0 && n==4 && o!=0)
cout<<"Thousand ";
}
void under(int n,int o)
{
int i,z,k,l,m,a;
for(i=0; i<o; i++)
{
z=n%10;
n=n/10;
if(i==1)
k=z;
else if(i==0)
l=z;
else if(i==4)
m=z;
else if(i==3)
a=z;
}
p(z,o,m,k);
ta(o,k,l,m,a,z);
b=k;
e=l;
}
void r(int n)
{
if(n==0);
else if(n==1)
cout<<"One ";
else if(n==2)
cout<<"Two ";
else if(n==3)
cout<<"Three ";
else if(n==4)
cout<<"Four ";
else if(n==5)
cout<<"Five ";
else if(n==6)
cout<<"Six ";
else if(n==7)
cout<<"Seven ";
else if(n==8)
cout<<"Eight ";
else if(n==9)
cout<<"Nine ";
}
void p(int n,int k,int o,int y)
{
if(k!=2 && k!=5 && k!=1 && k!=4)
r(n);
else if(k!=2 && k!=5 && y!=1 && o!=1 && k!=1)
r(n);
}
int main()
{
int p=0,z,n;
cin>>x;
int i=0;
n=x;
for(; x>0; i++)
{
x=x/10;
z=x%10;
p++;
}
if(n==0)
{
cout<<"Zero";
return 0;
}
else if(p==1)
{
r(n);
}
else if(p>1)
{
for(i=0; p!=0; i++,p--)
{
under(n,p);
}
if(b!=1)
r(e);
}
}```

#### pankajgupta2828 Profile Answers by pankajgupta2828 Questions by pankajgupta2828

• Aug 2nd, 2017

Please also suggest a code for generalized number i.e for any number at least till crores.

#### ARTI SHUKLA

• Aug 9th, 2018

Look the error for 1012....1019......2012......2019.....and so on, CORRECT IT SIR!