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

@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;

Edited 3 Years Ago by Dani: Formatting fixed

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.

Edited 7 Years Ago by William Hemsworth: n/a

This article has been dead for over six months. Start a new discussion instead.