Help with a program for class...

This is a discussion on Help with a program for class... within the C Programming forums, part of the General Programming Boards category; Class question: "To perform an addition such as 3+4, two sticks can be placed side-by-side, with the '0' of the ...

  1. #1
    Registered User
    Join Date
    Aug 2006
    Posts
    2

    Help with a program for class...

    Class question:


    "To perform an addition such as 3+4, two sticks can be placed side-by-side, with the '0' of the upper stick next to the '3' of the lower stick. The result of the computation can then be read off by looking for the number on the lower stick which lines up with the '4' on the upper stick:
    Code:
          +-------------------+
          |0 1 2 3 4 5 6 7 8 9|
    +-----+-------------+-----+
    |0 1 2 3 4 5 6 7 8 9|
    +-------------------+
                   ^
    (picture won't work, but the 0 is in line with bottom 3, so the 7 is below the 4(top).)

    Stage 1: Addition
    Write a C program which reads an integer, a character, and another integer from standard input, and prints to standard output a picture of the corresponding computing stick computation, in the format shown above. Note:

    the two integers will be between 1 and 9 (inclusive)
    the horizontal and vertical edges of the sticks should be drawn using the characters '-' and '|'
    the corners of the sticks should be drawn as '+'
    an up-arrow '^' should be printed to point to the result of the computation
    your program should not print any tabs; it should only print spaces ' ', and it should not print any additional blank spaces at the end of any line
    the order of the numbers is important; the computation for 4+3 should look different from that of 3+4 "

    I am getting stuck with the movement of these 'sticks', any tips would be appreciated.
    Last edited by Dave_Sinkula; 08-07-2006 at 11:43 AM. Reason: Added [code][/code] tags to preserve whitespace.

  2. #2
    ex-DECcie
    Join Date
    Dec 2005
    Posts
    125
    We had this one in here last week as I recall....

    Dig around -- I can't remember if much advice was given, but what was given should still be here on the board.
    Mr. Blonde: You ever listen to K-Billy's "Super Sounds of the Seventies" weekend? It's my personal favorite.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Issue with program that's calling a function and has a loop
    By tigerfansince84 in forum C++ Programming
    Replies: 9
    Last Post: 11-12-2008, 12:38 PM
  2. Need help with a program, theres something in it for you
    By engstudent363 in forum C Programming
    Replies: 1
    Last Post: 02-29-2008, 12:41 PM
  3. Replies: 4
    Last Post: 02-21-2008, 09:39 AM
  4. My program, anyhelp
    By @licomb in forum C Programming
    Replies: 14
    Last Post: 08-14-2001, 10:04 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21