Anonymous
Anonymous asked in Science & MathematicsMathematics · 7 months ago

math master or IT master please help me solve this?

Attachment image

2 Answers

Relevance
  • 7 months ago
    Favorite Answer

    Master? Anyone with a simple understanding of programming 101 can solve this. (I could have known how to do this when I was 10).

    You have four variables with pre-set values:

    a = 5, b = 2, c = 4, d = 4

    If a ≤ c do the next four steps (it isn't as "a" is larger).

    Then go down to the else if. If a < d, do the next four steps (again, it isn't)

    So you do the logic in order in the else state:

    a = (b - c) * d

    a = (2 - 4) * 4

    a = -2 * 4

    a = -8 (a now has a new value that will be used in the following three steps, etc.)

    b = a * ((b + c) / d) (use the old value of "b", then replace what you get into "b":

    b = -8 * ((2 + 4) / 4)

    b = -8 * (6 / 4)

    Now that we have to divide, you have the // symbol (vs. / symbol) which is a floor division. So whatever result you get rounds down to the previous integer. 6/4 = 1.5, so the result of this is 1.

    b = -8 * 1

    b = -8

    Now b has a new value, on to c:

    c = ((a - b) / c) * d

    c = ((-8 - (-8)) / 4) * 4

    c = ((-8 + 8) / 4) * 4

    c = (0 / 4) * 4

    c = 0 * 4

    c = 0

    Finally, d:

    d = a * (b - c % d)

    % is the mod operator. It returns the remainder when the two numbers are divided. So the result is always a number between 0 and (d - 1):

    d = -8 * (-8 - 0 % 4)

    0 mod *anything* is 0, so:

    d = -8 * (-8 - 0)

    d = -8 * (-8)

    d = 64

    So the end result is:

    a = -8, b = -8, c = 0, d = 64

    • Login to reply the answers
  • Anonymous
    7 months ago

    a= a is 5 bigger than all the rest so last else is the branch executed.

    a=-8

    b=-8

    c=0

    d=64

    • Login to reply the answers
Still have questions? Get your answers by asking now.