Are you sure you want to delete this answer?

Are you sure you want to delete this answer?

Sorry, something has gone wrong.

Best 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

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

llaffer
· 1 month ago

2

Thumbs up
0

Thumbs down
Asker's rating

If you believe your intellectual property has been infringed and would like to file a complaint, please see our Copyright/IP Policy

Report Abuse

Cancel

If you believe your intellectual property has been infringed and would like to file a complaint, please see our Copyright/IP Policy

Report Abuse

Cancel

If you believe your intellectual property has been infringed and would like to file a complaint, please see our Copyright/IP Policy

Report Abuse

Cancel

- Upload failed. Please upload a file larger than 100x100 pixels
- We are experiencing some problems, please try again.
- You can only upload files of type PNG, JPG, or JPEG.
- You can only upload files of type 3GP, 3GPP, MP4, MOV, AVI, MPG, MPEG, or RM.
- You can only upload photos smaller than 5 MB.
- You can only upload videos smaller than 600MB.
- You can only upload a photo (png, jpg, jpeg) or a video (3gp, 3gpp, mp4, mov, avi, mpg, mpeg, rm).
- You can only upload a photo or a video.
- Video should be smaller than <b>600mb/5 minutes</b>
- Photo should be smaller than <b>5mb</b>
- You can only upload a photo.
- Video should be smaller than <b>600mb/5 minutes</b>Photo should be smaller than <b>5mb</b>

Trending

14 answers

10 answers