A does not match because it changes the order of operations by prioritizing addition/subtraction.
B will produce a syntax error, as it includes 2 open parentheses, but 3 closing parentheses.
C will produce a syntax error, as it includes 3 open parentheses, but 2 closing parentheses.
This leaves D as the correct answer.
The expression in the function is:
value = a + b * c - d
According to the order of operations (PEMDAS/BODMAS), multiplication is performed before addition and subtraction. Therefore, the expression can be rewritten with parentheses to make the order of operations explicit:
value = a + (b * c) - d
This matches option B:
B. (a + (b * c)) - d)
So, the correct answer is:
B. (a + (b * c)) - d)
B is correct. Multiplication has higher precedence than addition and substraction. Then for addition and substraction with the same precedence, left associativity is applied.
b is the correct answer
According to the order of operations (PEMDAS/BODMAS), multiplication is performed before addition and subtraction.
Specifically:
Multiplication: b * c
Addition: a + (result of b * c)
Subtraction: (result of a + b * c) - d
Answer D is correct. None of the above.
A is wrong since multiplication has higher precedence than addition/subtraction
B has a closing ")" too much
C has an opening "(" too much
upvoted 3 times
...
Log in to ExamTopics
Sign in:
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.
Upvoting a comment with a selected answer will also increase the vote count towards that answer by one.
So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.
keryn
3 weeks, 3 days agohovnival
1 month, 1 week ago5cd303a
2 months, 3 weeks agoFedeXD
4 months, 1 week agoDelroy2826
5 months, 1 week agoS1nthe0
5 months, 1 week agochristostz03
5 months, 2 weeks agoherrmann69
8 months ago