Making a program which returns text from numbers

Hello guys,
I am currently a beginner in programming. I am trying to write a program in C++.

Apparently, the program should return text from numbers; upto million should be alright, if not then up thousands is ok. I havent gotten into OOP, this problem could be solved using "structured programming method" but I am out of ideas, any help will be appreciated.
Last edited on
1) Create array with the words that will be uses up to one million.
ex: one , two , three ... , twenty , thirty , .... , hundred , thousand , million
*if they are in order hundred is index 27 , thousand index 28 , million index 29

2) create a function and a vector inside of it like *vector if it is a for loop* if it is not a for loop use a string inplace of my vector
1
2
3
4
void number_to_word( unsigned long &number )
{
    std::vector<std::string> number( 0 );
}


3)
iterate through the numbers
1
2
3
4
for( auto i( 0 ); i < 1000; ++i )
{
    auto temp( i + 1 ); //makes life easier
}


or just use the number you are actually using.
1
2
number_to_word( number );
number_to_word( ... ){ auto temp( number ); }


4) use an if statement for > 999,999,999 , > 1000 , > 20.
5) ON the first if statement that is *true you want to do something like
number.push_back( words_array[ temp / /*1e6, 1e3 , 1e2 , 1e1*/ - 1 ] + temp[ words_array[ /*position for 1e6 , 1e3 , 1e3 , 1e1 */ ];
temp %= /* 1e6 , 1e3 , 1e2 , 1e1 */

on the if statements after that you want to do something like
//if it is in a loop
numbers[ i ] += ... /* next info for the number */
otherwise
numbers += /*next info for the number


*true means you have to have another if statement inside of that one seeing if it the original value is greater than the current value.


Thanks a bunch.....really saved my life!
No problem I was actually doing this the other day with one of the euler projects they are pretty fun.
Topic archived. No new replies allowed.