answersLogoWhite

0


Best Answer

/*mycfiles.wordpress.com
program to convert digits to character*/
#include
#include
void main()
{
int a[5],i,n;
clrscr();
cout<<"Enter the Value";
cin>>n;
for(i=4;i>=0;i--)
{
a[i]=n%10;
n=n/10;
}
for(i=0;i<5;i++)
{
if(a[i]!=0)
{
switch(a[i])
{
case 0:cout<<"Zero";
break;
case 1:cout<<"One";
break;
case 2:cout<<"Two";
break;
case 3:cout<<"Three";
break;
case 4:cout<<"Four";
break;
case 5:cout<<"Five";
break;
case 6:cout<<"Six";
break;
case 7:cout<<"Seven";
break;
case 8:cout<<"Eight";
break;
case 9:cout<<"Nine";
break;
}
}
}
getch();
}


------------------------------------------------------------------------------------


Program to Convert Numbers into Words

#include

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: ");
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);
}


// for any query visit
// "http://www.c.happycodings.com/Beginners_Lab_Assignments/code51.html"

Program to Convert Numbers into Words

#include

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: ");
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);
}


// for any query visit
// "http://www.c.happycodings.com/Beginners_Lab_Assignments/code51.html"

User Avatar

Wiki User

13y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

14y ago

/**

* Note: this should work for all 0 <= num < 1,000,000,000

* @return a String representing the English-word value of num

*/

public static final String numberToWord(final int num) {

// special case to simplify later on

if (num == 0) {

return "zero";

}

// constant number names for each category

// single digits

final String n_1_9[] = new String[]{"", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine"};

// unfortunate special cases for ten, eleven, twelve, and teens

final String n_10_19[] = new String[]{"ten", "eleven", "twelve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen", "eighteen", "nineteen"};

// tens

final String n_20_90[] = new String[]{"", "twenty", "thirty", "forty", "fifty", "sixty", "seventy", "eighty", "ninety"};

final String n_100 = "hundred";

final String n_1000 = "thousand";

final String n_1000000 = "million";

// use StringBuilder for efficient modifications

StringBuilder numWord = new StringBuilder();

int n = num;

// append with selective recursion for all our cases

if (n >= 1000000) {

numWord.append(numberToWord(n / 1000000));

numWord.append(' ');

numWord.append(n_1000000);

numWord.append(' ');

n %= 1000000;

}

if (n >= 1000) {

numWord.append(numberToWord(n / 1000));

numWord.append(' ');

numWord.append(n_1000);

numWord.append(' ');

n %= 1000;

}

if (n >= 100) {

numWord.append(n_1_9[n / 100]);

numWord.append(' ');

numWord.append(n_100);

numWord.append(' ');

n %= 100;

}

if (n >= 20) {

numWord.append(n_20_90[(n / 10) - 1]);

numWord.append(' ');

n %= 10;

}

if (n >= 10) {

numWord.append(n_10_19[n - 10]);

}

if (n < 10) {

numWord.append(n_1_9[n]);

}

return numWord.toString().trim();

}

This answer is:
User Avatar

User Avatar

Wiki User

14y ago


//Program to Print a Number into Word (Between 1 to 9)

#include
#include
void main()
{
int n;
clrscr();
printf("Enter number between 1-9:");
scanf("%d",&n);
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;
default:
printf("Contains More than 1 Digit");
}
getch();
}

output:
Enter number between 1-9:
2
Two
Enter number between 1-9:
230
Contains More than 1 Digit

This answer is:
User Avatar

User Avatar

Wiki User

13y ago

All you need to do is explain to your teacher how it works.

public class Main {

public static void main(String[] av) { System.out.println(cvt(12345)); }

static String ten[] = { "", " ten", " twenty", " thirty", " fourty",

" fifty", " sixty", " seventy", " eighty", " ninety" };

static String one[] = { "", " one", " two", " three", " four",

" five", " six", " seven", " eight", " nine",

" ten", " eleven", " twelve", " thirteen", " fourteen",

" fifteen", " sixteen", " seventeen", " eighteen", " nineteen" };

static String cvt(int a) { return cvt5(a).substring(1);}

static String cvt5(int a) { return (a >= 1000 ? cvt3(a / 1000) + " thousand" : "") + cvt3(a % 1000); }

static String cvt3(int a) { return (a >= 100 ? cvt2((a / 100)%10) + " hundred" : "") + cvt2(a % 100); }

static String cvt2(int a) { return a < 20 ? one[a] : (ten[a / 10] + one[a % 10]); }

}

This answer is:
User Avatar

User Avatar

Wiki User

12y ago

class abc

{

void main( int num )

{

int d = 1;

int dig = 0;

int temp = num;

System.out.println(temp);

while(num > 9)

{

num = num / 10 ;

d = d * 10;

}

while( d != 0)

{

dig = temp / d;

if( dig 0)

System.out.print("Zero");

temp = temp - (dig * d);

d = d / 10 ;

}

}

}

This answer is:
User Avatar

User Avatar

Wiki User

14y ago

Your question is inconclusive. Please provide an example of what you are trying to achieve

This answer is:
User Avatar

User Avatar

Wiki User

9y ago

Write a program enters the ten-digit number and prints

Using the largest for

This answer is:
User Avatar

User Avatar

Wiki User

12y ago

write a java program to implement Dynamic method dispatch

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Write a program that accepts a number and output its equivalent in words?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

Is microphones input or output device?

A Microphone does not output sound. It accepts sound. It is an input device.


What mathematical program can solve the highest number puzzle?

Any program whose output is: " Don't waste your time! There is no highest number. Never was, never will be."


What is accuracy of a good program?

It depends on to what level of accuracy you tend to have with the output of your program Accuracy can be treated as: (Desired Output / Actual Output of your Program)


Is a program with no input an incorrect program?

No, as long as it calculates something, displays something, or otherwise has an output that benefits the user, it is a program. It could be a program that makes a random number, or a program that tells the user a joke from a database.


How do you code a program to scan a number n and then output the sum of the power from 1 to n?

help me now !!


Which documentation is typically written first input output internal program or external program?

Output documentation


Design and draw a combinational circuit using AND-OR-NOT gates that accepts 4 input bits and produces two bit output the first of the two bits is set to 1 if the number of 1s in the input is even?

Design and draw a combinational circuit using AND-OR-NOT gates that accepts 4 input bits, and produces two bit output; the first of the two bits is set to 1 if the number of 1's in the input is even; and the second of the output bit is set to 1 if the input have 3 or more (all four) 1 bits.


What is input -output bound program?

input output bound program is a program (or process in precise way), which spends most of time allocated to it for execution, on input/output devices and need very small CPU time for it.


Design a combinational circuit that accepts a three bit number and generates a binary output equal to twice the input value?

There is no need for a combinatorial circuit to multiply a number by two. A binary number, left shifted one place, is twice the original binary number. The specific answer to the question is that you would connect the three input lines to the three high order output line of four output lines, and connect the low order bit of the four output lines to logic 0. If the three input lines were labelled A, B, and C, the output would be A, B, C, and 0.


What are the four steps a computer follows?

It accepts input, processes data, stores data, and produces output.


Can A Computer Output Electricity In Computercraft you can say if true output power on this side Can you say in a program to output power say to light a light So if true then output power to led's?

A Computer Output Electricity in Computercraft cannot be said to make a program to output power, regardless of the side.


How do you append a output of a program to a program?

you mean like show some sample output? Just put it in comments at the bottom. Run the program, and in the top left of the command prompt there is a button you can click. Select mark, highlight the output, then select copy. Paste it onto the end of the program.