need a program.

aravindan333's Avatar, Join Date: Dec 2010
Newbie Member
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
xpi0t0s's Avatar, Join Date: Aug 2004
Mentor
This isn't a difficult program to write, more tedious than difficult. Where are you stuck?
aravindan333's Avatar, Join Date: Dec 2010
Newbie Member
Boss, I don't have any idea of the program, Can u please help me
xpi0t0s's Avatar, Join Date: Aug 2004
Mentor
Why do you need the program? Are you on a course?
shabbir's Avatar, Join Date: Jul 2004
Go4Expert Founder
Quote:
Originally Posted by aravindan333 View Post
Boss, I don't have any idea of the program, Can u please help me
Nope.
aravindan333's Avatar, Join Date: Dec 2010
Newbie Member
yea, i was on course, please help me
xpi0t0s's Avatar, Join Date: Aug 2004
Mentor
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.
virxen's Avatar, Join Date: Nov 2009
Pro contributor
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..
kevie's Avatar, Join Date: Dec 2010
Newbie Member
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
xpi0t0s's Avatar, Join Date: Aug 2004
Mentor
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.