how can i make a program that the computer will allow the usser to input a number.. then it will turn into a word?
example:
1030=one thousand thirty

Recommended Answers

All 4 Replies

Tried searching the internet? [link]
This is a very commonly asked question, show us your code so far and we'll help you if you get stuck.

@William Hemsworth
im stuck at the very begining i dont have any idea in programing, im just a bigginer.. i try posting at this forum so i can find some help.. here is my code even it is no sense.. but if you can help me ill thank u a lot..

#include <iostream>
using namespace std;
int main()
{
    int x,y;
    cout<<"enter a number:";
    cin>>x;

Well, anything's better than nothing I guess. Remember, use code-tags in your posts or I wont bother responding.
This is what you have so far:

#include <iostream>
using namespace std;

int main()
{
  int x, y;
  cout << "enter a number:";
  cin >> x;
}

Now you should create a frame for your program, remember, one thing at a time. You need a function to convert an integer to words, and for that you first need a function to read individual digits, be happy I wrote that for you.

#include <iostream>
using namespace std;

// Works right to left
int getDigit(int value, int digitIndex) {
  while ( digitIndex-- ) {
    value /= 10;
  }

  return value % 10;
}

void toWords(int number, char *buffer) {
  [B]// Your turn[/B]
}

int main()
{
  int x, y;
  char text[100];

  cout << "Enter a number: ";
  cin >> x;

  toWords( x, text );
  cout << "Text: " << text;
}

This is one of many ways to do this, may not be the best. Now I want to see some effort from you.

ok tnx.. ill try 2 study and comlete this code.. tnx 2 u

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.