Experts are full of valuable knowledge and are ready to help with any question. Credentials confirmed by a Fortune 500 verification firm.

Get a Professional Answer

Via email, text message, or notification as you wait on our site. Ask follow up questions if you need to.

100% Satisfaction Guarantee

Rate the answer you receive.

Ask Raj Your Own Question

Raj, Engineer

Category: Homework

Satisfied Customers: 1284

Experience: 4 + Experiance in IT Industry

16752232

Type Your Homework Question Here...

Raj is online now

IntroductionOne of the earliest known computing devices

This answer was rated:

★★★★★

Introduction

One of the earliest known computing devices consisted of a set of wooden sticks with numbers carved into them like this:+-------------------+ |0 1 2 3 4 5 6 7 8 9| +-------------------+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:+-------------------+ |0 1 2 3 4 5 6 7 8 9| +-----+-------------+-----+ |0 1 2 3 4 5 6 7 8 9| +-------------------+ ^

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

when the result is larger than 9, two sticks should be placed next to each other; for example, the result of 5+8 should look like this: +-------------------+ |0 1 2 3 4 5 6 7 8 9| +---------+---------+---------+---------+ |0 1 2 3 4 5 6 7 8 9|0 1 2 3 4 5 6 7 8 9| +-------------------+-------------------+ ^

Stage 2: Subtraction

Now extend your program to handle subtraction. For example, in order to compute 7-5, the '5' of the upper stick should line up with the '7' of the lower stick, and the up-arrow '^' should line up with the '0' of the upper stick, thus pointing to the result on the lower stick:

+-------------------+ |0 1 2 3 4 5 6 7 8 9| +---+---------------+---+ |0 1 2 3 4 5 6 7 8 9| +-------------------+ ^In situations where the result is negative, a down-arrow should be printed above the top stick. For example, the computation for 5-7 should look like this (indicating that the result is negative 2):v +-------------------+ |0 1 2 3 4 5 6 7 8 9| +---+---------------+---+ |0 1 2 3 4 5 6 7 8 9| +-------------------+

Stage 3: Multiplication

The computing-stick method can also be extended to multiplication. As an illustration, we explain in detail the computation of 3*5

Place one stick vertically on the left side of the workspace.

Place 5 sticks horizontally, lining up with the 0, 1, 2, 3 and 4 of the vertical stick; the 0 of each new stick should line up vertically with the 3 of the previous stick.

Place a series of sticks horizontally, lining up with the 5 of the vertical stick, until you reach the 3 of the stick in the row above. Print an up-arrow ^ to point to whatever number lines up with the 3 on that stick.

The result of the computation will generally be a two digit number. The last digit is the one pointed to by the up-arrow (in this case 5). The first digit is the number of (whole) sticks to the left of the up-arrow (in this case 1). Thus, the result of the multiplication is 15.

Hello. I am a moderator for this topic. Unfortunately, the prior professional is unavailable to answer. I have reopened your question to all the professionals for this topic and marked it high priority. You will receive an email notification as soon as you have a new reply. Thank you for your patience.

UPDATE: Multiplication is also ready. Just formatting result is stuck. I am working on it. Effort required to solve it was way more than question price so I have sent an underprice report indicating new price. Please go through it and see whether that's fine with you?

I can't compile this file,this is the wrong message.can you help me, and can you make comments for some of part to let me to easy to understand.Thank you a lots.

One more problem,after each operation I have to press enter then the operation finish,can you help me to fix it up,please,Thank you Thank you Thank you so so much.

Are you online ,it's just the programming you gave to me has a little problem, mainly is Multiplication operation. can you help me to fix it up.I have to pass the test for, 2*9,9*1,4*2,2*5,5*3,3*6,it is just slightly different,please help me.

Attachments are only available to registered users.