Ask Question
22 April, 08:21

Given the following segment of code,

/ / postcondition:returns x + y public int add (int x, int y) {}

/ / postcondition:return x * y public int multiply (int x, int y) {}

which of the following corresponds to this expression?

multiply (add (multiply (a, b), add (multiply (a, c), multiply (b, c))), 2)

1. a * b + a * c + b * c * 2

2. a * b + a * c + b * c + 2

3. a * b + (a * c + b * c)

4. (a * b + a * c + b * c) * 2

5.2 * a * b + (a * c + b * c)

+1
Answers (1)
  1. 22 April, 08:29
    0
    The whole line of code that performs an operation is this one:

    multiply (add (multiply (a, b), add (multiply (a, c), multiply (b, c))), 2)

    Let's do it step by step:

    Step 1: Perform the inner group of parenthesis. Then expand going out, until you reach the bigger parenthesis.

    Just bear in mind that multiply () = x * y

    and add () = x + y

    Last step: Get the final expression

    ((a * b) + (a*c + b*c)) * 2
Know the Answer?
Not Sure About the Answer?
Get an answer to your question ✅ “Given the following segment of code, / / postcondition:returns x + y public int add (int x, int y) {} / / postcondition:return x * y public ...” in 📙 Computers & Technology if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers