Go4Expert

Go4Expert (http://www.go4expert.com/)
-   C (http://www.go4expert.com/forums/c/)
-   -   need a program. (http://www.go4expert.com/forums/need-a-program-t24234/)

aravindan333 22Dec2010 11:39

need a program.
 
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:pleased:

xpi0t0s 23Dec2010 12:39

Re: need a program.
 
This isn't a difficult program to write, more tedious than difficult. Where are you stuck?

aravindan333 23Dec2010 13:00

Re: need a program.
 
Boss, I don't have any idea of the program, Can u please help me:thinking:

xpi0t0s 23Dec2010 13:01

Re: need a program.
 
Why do you need the program? Are you on a course?

shabbir 23Dec2010 13:10

Re: need a program.
 
Quote:

Originally Posted by aravindan333 (Post 76268)
Boss, I don't have any idea of the program, Can u please help me:thinking:

Nope.

aravindan333 26Dec2010 09:27

Re: need a program.
 
yea, i was on course, please help me:worried:

xpi0t0s 29Dec2010 23:29

Re: need a program.
 
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 30Dec2010 06:15

Re: need a program.
 
Quote:

Originally Posted by aravindan333 (Post 76232)
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:pleased:


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.

kevie 31Dec2010 08:27

Re: need a program.
 
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 31Dec2010 19:23

Re: need a program.
 
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.


All times are GMT +5.5. The time now is 18:18.