Public Group

#### Archived

This topic is now archived and is closed to further replies.

# i'm hitting a brick wall

This topic is 6016 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hi all, I hope this will fit in this forum asI am a beginner. I''m currently using the book "Turbo C++ Programming 101" by Greg Perry, Published by Sams. I''m going to write the exercise down because I am in desperate need of a hint on how to proceed. (From the lesson Logical Operators: Combining Relational Operators) Write a program that asks the user for a number between 100 and 9999. Write the word description of the number the user enters. For example, if the user enters 576, your program should print Five Hundred Seventy Six Don''t worry about putting hyphens between the numbers. I posted this quite awhile back on another newsgroup but I received the reply that it was okay to skip this exercise as all it related to was busy work. I''d rather know how to accomplish it. Can anyone give me some hints? I am stumped! Mike

##### Share on other sites
Just some doodling...
  char * names = { "", "one ", "two ", "three ", "four ", "five ", "six ", "seven ", "eight ", "nine " };char * twentyplus = { "", "", "twenty ", "thirty ", "forty ", "fifty ", "sixty ", "seventy ", "eighty ", "ninety ";char * teens = { "ten ", "eleven", "twelve ", "thirteen ", "fourteen ", "fifteen ", "sixteen ", "seventeen ", "eighteen ", "nineteen " };int number = 576;int thousands = number/1000;if(thousands) cout << names[thousands] << "thousand ";number -= thousands*1000;int hundreds = number/100;if(hundreds) cout << names[hundreds] << "hundred ";number -= hundreds*100;int tens = number/10;number -= tens*10;if(tens == 1) cout << teens[number] << "\r\n";else cout << twentyplus[tens] << names[number] << "\r\n";

The best way to learn programming is reading through it slowly. Read through it line by line, step by step, just as the program will run. It''ll make sense.

---email--- Tok ----surf----
~The Feature Creep of the Family~

##### Share on other sites
Types should be char* names[]
...

##### Share on other sites
Doh... your right! ...Well, I did say I was "doodling", right?
lol

char * names [] = { "", ...ect.

---email--- Tok ----surf----
~The Feature Creep of the Family~

##### Share on other sites
Beware the language lawyer.

Edited by - Fruny on January 30, 2002 4:08:32 AM

1. 1
2. 2
3. 3
Rutin
24
4. 4
JoeJ
18
5. 5

• 14
• 23
• 11
• 11
• 9
• ### Forum Statistics

• Total Topics
631766
• Total Posts
3002232
×