need a program.

Newbie Member
22Dec2010,11:39   #1
aravindan333's Avatar
Hi guys, i need rough code for a program.The question is as follows,
pgm:
if you press 1 in your keyboard, it have to display in letters "one", similarly it should display upto a three digit number 101----->"one hundred and one", i need the code in c++, i just need the logic don't need to be very accurate. If you guys have any idea post it here please
Mentor
23Dec2010,12:39   #2
xpi0t0s's Avatar
This isn't a difficult program to write, more tedious than difficult. Where are you stuck?
Newbie Member
23Dec2010,13:00   #3
aravindan333's Avatar
Boss, I don't have any idea of the program, Can u please help me
Mentor
23Dec2010,13:01   #4
xpi0t0s's Avatar
Why do you need the program? Are you on a course?
Go4Expert Founder
23Dec2010,13:10   #5
shabbir's Avatar
Quote:
Originally Posted by aravindan333 View Post
Boss, I don't have any idea of the program, Can u please help me
Nope.
Newbie Member
26Dec2010,09:27   #6
aravindan333's Avatar
yea, i was on course, please help me
Mentor
29Dec2010,23:29   #7
xpi0t0s's Avatar
OK, so if you're on a course, why do you have no idea how to start? Have you not been paying attention? Did the course specify some pre-requisite skills that you don't have? Or do you just have a crap teacher?

Just giving you the code is no help. You won't learn anything from it, even though you might kid yourself that you will. If you've been doing the exercises you've been given then you should have some idea at least how to get going, even if you can't manage to write the whole thing. The main problem with giving you the code, if the teacher accepts it as your submission for the assignment, that your teacher has no idea that you're struggling and can't do anything about it. If he knows you have a problem then there's a chance he can do something about it before the exam.
Pro contributor
30Dec2010,06:15   #8
virxen's Avatar
Quote:
Originally Posted by aravindan333 View Post
Hi guys, i need rough code for a program.The question is as follows,
pgm:
if you press 1 in your keyboard, it have to display in letters "one", similarly it should display upto a three digit number 101----->"one hundred and one", i need the code in c++, i just need the logic don't need to be very accurate. If you guys have any idea post it here please

1) read the numbers from the user
2) check to see if the number is >=0 and <=999 (up to 3-digit number)
if not goto 1
3)declare a char array to hold your answer
4)declare a char array ([][])to contain "zero","one",....."ten","eleven",..."twenty"
declare a char array to contain "ten","twenty",...."ninety"
5) include string.h in your code
6) use strcpy,strcat to create the correct answer

start coding and post your code here to help you.

Last edited by virxen; 30Dec2010 at 06:19..
Newbie Member
31Dec2010,08:27   #9
kevie's Avatar
make the figure to have to be inputted in three figures to make it simple. so 3 will have to be typed 003



display [HUNDREDS] hundred and [TENS] [UNITS] [TEENS]

if HUNDREDS = 0

display [TENS][UNITS]

if TENS = 1 and units = 0 then display TEENS.

etc etc you work it out im tired. ;D
Mentor
31Dec2010,19:23   #10
xpi0t0s's Avatar
if it's less than 20 you have to display a specific word.
if it's less than 100 then display one of "twenty, thirty, forty etc" and one of "<nothing>, one, two, three" etc.
if it's exactly 100,200,300 just display one of "one, two, three etc" plus "hundred"
if it's 101-199 or 201-299 etc display one of "one two three etc" plus "hundred and" plus the "less than 100" code.
Upper limit is 999 so that should just about cover it.

Come on, you really should have a go now. You've had more than enough hints. We're not going to write the code for you.