need a program.

Discussion in 'C' started by aravindan333, Dec 22, 2010.

  1. aravindan333

    aravindan333 New Member

    Joined:
    Dec 22, 2010
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    0
    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:
     
  2. xpi0t0s

    xpi0t0s Mentor

    Joined:
    Aug 6, 2004
    Messages:
    3,009
    Likes Received:
    203
    Trophy Points:
    63
    Occupation:
    Senior Support Engineer
    Location:
    England
    This isn't a difficult program to write, more tedious than difficult. Where are you stuck?
     
  3. aravindan333

    aravindan333 New Member

    Joined:
    Dec 22, 2010
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    0
    Boss, I don't have any idea of the program, Can u please help me:thinking:
     
  4. xpi0t0s

    xpi0t0s Mentor

    Joined:
    Aug 6, 2004
    Messages:
    3,009
    Likes Received:
    203
    Trophy Points:
    63
    Occupation:
    Senior Support Engineer
    Location:
    England
    Why do you need the program? Are you on a course?
     
  5. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83
    Nope.
     
  6. aravindan333

    aravindan333 New Member

    Joined:
    Dec 22, 2010
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    0
    yea, i was on course, please help me:worried:
     
  7. xpi0t0s

    xpi0t0s Mentor

    Joined:
    Aug 6, 2004
    Messages:
    3,009
    Likes Received:
    203
    Trophy Points:
    63
    Occupation:
    Senior Support Engineer
    Location:
    England
    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.
     
  8. virxen

    virxen Active Member

    Joined:
    Nov 24, 2009
    Messages:
    387
    Likes Received:
    90
    Trophy Points:
    28

    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: Dec 30, 2010
  9. kevie

    kevie New Member

    Joined:
    Dec 31, 2010
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    0
    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
     
  10. xpi0t0s

    xpi0t0s Mentor

    Joined:
    Aug 6, 2004
    Messages:
    3,009
    Likes Received:
    203
    Trophy Points:
    63
    Occupation:
    Senior Support Engineer
    Location:
    England
    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.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice