How JustAnswer Works:

  • Ask an Expert
    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
Raj, Engineer
Category: Homework
Satisfied Customers: 1266
Experience:  4 + Experiance in IT Industry
16752232
Type Your Homework Question Here...
Raj is online now
A new question is answered every 9 seconds

IntroductionOne of the earliest known computing devices

Resolved Question:

 


 


 


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:



  1. the two integers will be between 1 and 9 (inclusive)

  2. the horizontal and vertical edges of the sticks should be drawn using the characters '-' and '|'

  3. the corners of the sticks should be drawn as '+'

  4. an up-arrow '^' should be printed to point to the result of the computation

  5. 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

  6. the order of the numbers is important; the computation for 4+3 should look different from that of 3+4

  7. 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



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

  2. 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.

  3. 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.

  4. 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.


+-+-------------------+ |0|0 1 2 3 4 5 6 7 8 9| | +-----+-------------+-----+ |1| |0 1 2 3 4 5 6 7 8 9| | | +-----+-------------+-----+ |2| |0 1 2 3 4 5 6 7 8 9| | | +-----+-------------+-----+ |3| |0 1 2 3 4 5 6 7 8 9| | | +-----+-------------+-----+ |4| |0 1 2 3 4 5 6 7 8 9| | +-------------------+---+---------------+---+ |5|0 1 2 3 4 5 6 7 8 9|0 1 2 3 4 5 6 7 8 9| | +-------------------+-------------------+ |6| ^ | | |7| | | |8| | | |9| +-+ For all three stages, the numbers to be added, subtracted or multiplied will be between 1 and 9.


 

Submitted: 1 year ago.
Category: Homework
Expert:  jatechexpert replied 1 year ago.
hi

thanks for using justAnswer.com

when you need this
Customer: replied 1 year ago.

You have to use function to write this C program and give the comments.



 


 



 


Expert:  jatechexpert replied 1 year ago.
hi

when is due this
Customer: replied 1 year ago.

I just give you more information,I think the picture can better show the all information you need,tomorrow after is the due time.

Customer: replied 1 year ago.

I just give you more information,I think the picture can better show the all information you need,tomorrow afternoon is the due time.

Expert:  jatechexpert replied 1 year ago.
hi

let me check it
Customer: replied 1 year ago.

Ok, thanks.

Expert:  jatechexpert replied 1 year ago.

hi

ok i will inform you

Customer: replied 1 year ago.

Thanks a lots.

Expert:  Angela--Mod replied 1 year ago.
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.

Best,

Angela
Expert:  Raj replied 1 year ago.
Hi There,

I will be helping you with the Solution.
By When do you need the Solution file?

Thank you
Customer: replied 1 year ago.

Hi,right now I only have 8 hours to finish it. I hope you can help me.

Expert:  Raj replied 1 year ago.
yes i am working on it at present.
Customer: replied 1 year ago.

Thank you a lots!!!!

Expert:  Raj replied 1 year ago.
You are Welcome
Expert:  Raj replied 1 year ago.
UPDATE:

I have completed Implementation for Addition and Substraction.
Now Working with last part of Multiplication.
Customer: replied 1 year ago.

Thank you so so much!!!!!!!!!!

Expert:  Raj replied 1 year ago.
You Are Welcome.
Expert:  Raj replied 1 year ago.
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?
Customer: replied 1 year ago.

ok,let me check it out.

Customer: replied 1 year ago.

ok,I agree with price you reset, you have to make sure everything woks all right and do not increase price any more,is that ok for you?

Expert:  Raj replied 1 year ago.
No problem. I will have everything working and price won't increase more than that.
Its a deal from my side.
Customer: replied 1 year ago.

Hi, the price has been reset and thanks a lots your efforts!!!

Expert:  Raj replied 1 year ago.
You are welcome.
Can you update me how many hours are left for deadline?
Customer: replied 1 year ago.

4 hours and half.

Expert:  Raj replied 1 year ago.
Thank you for the information.
Code will be ready before that .. Mostly in next 2 hrs.
Customer: replied 1 year ago.

wow,Thanks a lots!!!!!!!!

Expert:  Raj replied 1 year ago.
You are Welcome.
Expert:  Raj replied 1 year ago.
Solution code file is ready.

Please download the code file containing Solution(Sticks.c) from the link below:
http://www.mediafire.com/?pe5dvlx3yt5g3ct

If you face any difficulty than feel free to ask for help.

If the solution file is satisfactory than Please don't forget to RATE the Answer.
It will hardly take few seconds to RATE my Answer

Thank You and Have a Good Day.
Customer: replied 1 year ago.

Thank you so much,let me check it out.

Customer: replied 1 year ago.

Hi


 


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.


erro message

Expert:  Raj replied 1 year ago.
Ok you use UNIX/LINUX.

Wait I will modify the code file to be used in Linux.
Customer: replied 1 year ago.

Thank you, XXXXX XXXXX please please please!!!

Expert:  Raj replied 1 year ago.
Delete the previous file I sent you and Download this copy and it will work for output:

http://www.mediafire.com/?827m2bawzvakwoz

OUTPUT SCREEN SHOTS ARE AS FOLLOWS:
ADDITION:
graphic

SUBSTRACTION:

graphic

MULTIPLICATION:
graphic

If you face any difficulty than feel free to ask for help.

If the solution file is satisfactory than Please don't forget to RATE the Answer.
It will hardly take few seconds to RATE my Answer

Thank You and Have a Good Day.
Customer: replied 1 year ago.

Thank you ,let me check.

Expert:  Raj replied 1 year ago.
I have also commented the code so now you can download the commented code copy with comments from the link below:

http://www.mediafire.com/?d4yhhkiev3y2sd6

NOTE: Both the codes are same just I have added comments in this version of code.

If you face any difficulty than feel free to ask for help.

If the solution file is satisfactory than Please don't forget to RATE the Answer.
It will hardly take few seconds to RATE my Answer

Thank You and Have a Good Day.
Customer: replied 1 year ago.

Hi Master,


 


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.Smile

Expert:  Raj replied 1 year ago.
In the code when you go at the bottom you will see two getchar();

DELETE BOTH
: getchar(); at the bottom and your problem of hitting ENTER will be solved.

If you face any difficulty than feel free to ask for help.

If the solution file is satisfactory than Please don't forget to RATE the Answer.
It will hardly take few seconds to RATE my Answer

Thank You and Have a Good Day.
Customer: replied 1 year ago.

ok, I get it , and another small problem, you can see the picture.


small


 


you can see after operation, there are more -------+,it is suppose not have that one.Can you help me to change it,Sorry to disturb you so much.

Expert:  Raj replied 1 year ago.
Sorry forgot to mention this In first function delete the below part of code:

if(no == 2 && extra > 0)
{
printf("+");
for(i = 1; i<(extra); i++)
{
printf("-");
}
}

And it will disappear. It was part of my experiment which didnot work.
Expert:  Raj replied 1 year ago.
Download the Fresh copy of code from the link below with all the changes:

http://www.mediafire.com/?cqhgtyyr263dmra

If you face any difficulty than feel free to ask for help.

If the solution file is satisfactory than Please don't forget to RATE the Answer.
It will hardly take few seconds to RATE my Answer

Thank You and Have a Good Day.
Customer: replied 1 year ago.

It works perfectly, Thank you so much!!! And can you send me a link that I can pay for you.

Expert:  Raj replied 1 year ago.
Actually to Pay me you just have to RATE this Solution with the Best Rating you can give and I get paid after the Rating.

In Future to request any new Question to me just begin your Question with TO RAJ followed by the Question in the following format:

TO RAJ: Followed by the Question.

Have a Good Day.
Customer: replied 1 year ago.

Hi, Raj


 


I just asked my classmate, he told me we cannot use code like this


 


void


1


 


,2


we have to write like this


 


int main (void)


 


just last thing, so so so so sorry about that.!!!


 

Expert:  Raj replied 1 year ago.
THIS ANSWER IS LOCKED!

You need to spend $3 to view this post. Add Funds to your account and buy credits.
Raj, Engineer
Category: Homework
Satisfied Customers: 1266
Experience: 4 + Experiance in IT Industry
Raj and 5 other Homework Specialists are ready to help you
Customer: replied 1 year ago.

OK!!!!!!!


 


Thank you a lots for all of this!!!

Expert:  Raj replied 1 year ago.
Thank you for your Rating and Bonus.

In future if you want to request any new question to me than just begin your question with TO RAJ followed by the question as follows:

TO RAJ: question goes here....

Have a Good Day
Customer: replied 1 year ago.

Sure, Thank you so much!!!!!!

Expert:  Raj replied 1 year ago.
You are welcome.

Have a good day
Customer: replied 1 year ago.

Hi,Raj


 


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.

Register Here

Attachments are only available to registered users.

Register Here

Attachments are only available to registered users.

Register Here
View Full Image

Attachments are only available to registered users.

Register Here


 


it is suppose not have the more ++


like this


Attachments are only available to registered users.

Register Here

Attachments are only available to registered users.

Register Here

Attachments are only available to registered users.

Register Here
View Full Image

Attachments are only available to registered users.

Register Here

Expert:  Raj replied 1 year ago.
Yes I am online.
Give me few min and I will solve it and post the fresh solution.
Customer: replied 1 year ago.

okOK,sorry to disturb you so much,I really appreciate it, thank you thank you so much!!

Expert:  Raj replied 1 year ago.
No Problem I was awake.
Working on it now.
Customer: replied 1 year ago.

Thank you!!

Customer: replied 1 year ago.

especial 1*9 and 9*1 is different.

Expert:  Raj replied 1 year ago.
UPDATE:
9 * 1 is working, I have corrected it.
Now working on 1 * 9
Customer: replied 1 year ago.

okok.

Expert:  Raj replied 1 year ago.
Download the Fresh copy of code from the link below with all the changes:

http://www.mediafire.com/?z9eaq105llzb3b2

Thank You and Have a Good Day.
Customer: replied 1 year ago.

ok,let me check.

Customer: replied 1 year ago.

it is just like 5*3, 4*2, 7*2,you can see more ++ outside.

Expert:  Raj replied 1 year ago.
Ok Give me some time to come out with a good logic for that...
Customer: replied 1 year ago.

ok.

Customer: replied 1 year ago.
Hi Raj,I know I disturbed you a lot, I only have 4 hours till the last due time,Please please help me.
Expert:  Raj replied 1 year ago.
Yes don't worry I am working on the code. I will come up with a solution within 2 hrs. From now
Customer: replied 1 year ago.
Thank u Thank u so so much!
Expert:  Raj replied 1 year ago.
Ok I have tried all the given combination by you and they are working now.

Download the Updated version of code from the link below with all the changes:

http://www.mediafire.com/?qngm103tt7u082o

Thank You and Have a Good Day.
Customer: replied 1 year ago.
Ok,Let me try
Customer: replied 1 year ago.

Hi,Raj


I test the code on the school server, you can see still have 2 failed.


Attachments are only available to registered users.

Register Here

Attachments are only available to registered users.

Register Here

Attachments are only available to registered users.

Register Here
View Full Image

Attachments are only available to registered users.

Register Here

Customer: replied 1 year ago.

There are still something wrong with 9*1 and 4*2

Customer: replied 1 year ago.

Raj,Raj,


I really need you ,it just when doing like 9*1 or 2*3,the result is one digit,it should be print only one stick and the bottom,


Attachments are only available to registered users.

Register Here

Attachments are only available to registered users.

Register Here

Attachments are only available to registered users.

Register Here
View Full Image

Attachments are only available to registered users.

Register Here


 


It is suppose to only have one 0-9,no extra 0-9

JustAnswer in the News:

 
 
 
Ask-a-doc Web sites: If you've got a quick question, you can try to get an answer from sites that say they have various specialists on hand to give quick answers... Justanswer.com.
JustAnswer.com...has seen a spike since October in legal questions from readers about layoffs, unemployment and severance.
Web sites like justanswer.com/legal
...leave nothing to chance.
Traffic on JustAnswer rose 14 percent...and had nearly 400,000 page views in 30 days...inquiries related to stress, high blood pressure, drinking and heart pain jumped 33 percent.
Tory Johnson, GMA Workplace Contributor, discusses work-from-home jobs, such as JustAnswer in which verified Experts answer people’s questions.
I will tell you that...the things you have to go through to be an Expert are quite rigorous.
 
 
 

What Customers are Saying:

 
 
 
  • Wonderful service, prompt, efficient, and accurate. Couldn't have asked for more. I cannot thank you enough for your help. Mary C. Freshfield, Liverpool, UK
< Last | Next >
  • Wonderful service, prompt, efficient, and accurate. Couldn't have asked for more. I cannot thank you enough for your help. Mary C. Freshfield, Liverpool, UK
  • This expert is wonderful. They truly know what they are talking about, and they actually care about you. They really helped put my nerves at ease. Thank you so much!!!! Alex Los Angeles, CA
  • Thank you for all your help. It is nice to know that this service is here for people like myself, who need answers fast and are not sure who to consult. GP Hesperia, CA
  • I couldn't be more satisfied! This is the site I will always come to when I need a second opinion. Justin Kernersville, NC
  • Just let me say that this encounter has been entirely professional and most helpful. I liked that I could ask additional questions and get answered in a very short turn around. Esther Woodstock, NY
  • Thank you so much for taking your time and knowledge to support my concerns. Not only did you answer my questions, you even took it a step further with replying with more pertinent information I needed to know. Robin Elkton, Maryland
  • He answered my question promptly and gave me accurate, detailed information. If all of your experts are half as good, you have a great thing going here. Diane Dallas, TX
 
 
 

Meet The Experts:

 
 
 
  • Manal Elkhoshkhany

    Tutor

    Satisfied Customers:

    4522
    More than 5000 online tutoring sessions.
< Last | Next >
  • http://ww2.justanswer.com/uploads/BU/BusinessTutor/2012-2-2_115741_Kouki2.64x64.jpg Manal Elkhoshkhany's Avatar

    Manal Elkhoshkhany

    Tutor

    Satisfied Customers:

    4522
    More than 5000 online tutoring sessions.
  • http://ww2.justanswer.com/uploads/ComputersGuru/2010-02-13_051118_Photo41.JPG LogicPro's Avatar

    LogicPro

    Engineer

    Satisfied Customers:

    3458
    Expert in Java C++ C C# VB Javascript Design SQL HTML
  • http://ww2.justanswer.com/uploads/LI/lindaus/2012-6-10_04811_IMG20120609164157.64x64.jpg Linda_us's Avatar

    Linda_us

    Finance, Accounts & Homework Tutor

    Satisfied Customers:

    3124
    Post Graduate Diploma in Management (MBA)
  • http://ww2.justanswer.com/uploads/chooser77/2009-08-18_162025_Chris.jpg Chris M.'s Avatar

    Chris M.

    M.S.W. Social Work

    Satisfied Customers:

    2385
    Master's Degree, strong math and writing skills, experience in one-on-one tutoring (college English)
  • http://ww2.justanswer.com/uploads/JawaadAhmed/2009-6-27_12137_SIs_SHadi.jpg F. Naz's Avatar

    F. Naz

    Chartered Accountant

    Satisfied Customers:

    1988
    Experience with chartered accountancy
  • http://ww2.justanswer.com/uploads/JK/jkcpa/2011-1-16_182614_jkcpa.64x64.jpg Bizhelp's Avatar

    Bizhelp

    CPA

    Satisfied Customers:

    1876
    Bachelors Degree and CPA with Accounting work experience
  • http://ww2.justanswer.com/uploads/avremote/photoa.jpg Seanna's Avatar

    Seanna

    Tutor

    Satisfied Customers:

    1781
    3,000+ satisfied customers, all topics, A+ work
 
 
 

Related Homework Questions

Chat Now With A Tutor
Raj
Raj
Tutor
1266 Satisfied Customers
4 + Experiance in IT Industry