Q1
What is the result of the expression 5 + 7 * 2 in C?
A.
19
AnswerB.
24
C.
26
D.
17
Answer: Option A
Solution
Answer: Option A
Solution:
In C and many programming languages, mathematical expressions follow the operator precedence rules. Multiplication (*) and division (/) have higher precedence than addition (+) and subtraction (-).
So, when evaluating the expression "5 + 7 * 2," the multiplication is performed before addition:
5 + (7 * 2) = 5 + 14 = 19
Therefore, the result of the expression "5 + 7 * 2" in C is Option A: 19.