Question:

Can you correct this algorithm?

by  |  earlier

0 LIKES UnLike

The algorithm shown next should evaluate the expression a + b * c + 3 + c / 5, but it is not working correctly. Correct the algorithm.

1. add a to b 2. multiply the result of step 1 by c 3. add 3 to the result of step 2 4. add c to the result of step 3 5. divide the result of step 4 by 5

 Tags:

   Report

7 ANSWERS


  1. ((a+b)c+3+c)/5


  2. you should be using order of operations...

    multiplication and division (from left to right) come before addition and subtraction (also from left to right)

    1) multiply b by c

    2) divide c by 5

    3) add a to the result of (1)

    4) add 3 to the result of (3)

    5) add the results of (2) and (4)

    adding parentheses to clarify the order of operations:

    {[a + (b*c)] + 3} + (c/5)

    If no parentheses / brackets are given, you should follow PE(MD)(AS) for the order of operations:

    Parentheses

    Exponents

    Multiply / Divide from left to right

    Add / Subtract from left to right

  3. Reading the other responses, there appears to be a difference between the algorithm I see and others see it.

    To me the algorithm looks very unambigous and looks like this:  a  +b*c  + 3 +c/5. Others appear to see other things judging by their answers.

    Rule is that * and / (multiplying and dividing) comes before +  - (adding and subtracting).

    So, to solve your algorithm correctly

    multiply b*c  and divide c/5, then add to it a and 3 and c/5

    To see this in mathematical expression

    a +(b*c) + 3 +(c/5), however, your expression as written can only be interpreted one way and is perfectly legitimate

  4. If I did nt understand correctly, this is what it's all about:

    *  add 'a' to the the product of c  times c (there is parenthesis at a+b)

    *  add 3 plus 1/5 of c.

    Try that and see what happens. Good luck.


  5. 1.  multiply b times c.

    2.  divide c by 5.

    3.  add a + 3

    4.  add the results from step 1, 2, and 3.

    Finished.

  6. Your algorithm calculates the following expression:

    { [c(a+b)]+3 +c }/5

    What you are looking for is:

    1- Add a to b

    2- Add 3 to c

    3- Multiply the results of 1 and 2

    4- Divide c by 5

    5- Add the results of 4 and 3

      

  7. 1. Multiply b and c.

    2. Add a to the product in step 1.

    3. Add 3 to the sum of step 2.

    4. Divide c by 5.

    5. Add sum of step 3 to quotient of step 4.

    .

Question Stats

Latest activity: earlier.
This question has 7 answers.

BECOME A GUIDE

Share your knowledge and help people by answering questions.