What happens if you try to compile and run this program?

What happens if you try to compile and run this program?

#include <stdio.h>

int main(int argc, char *argv[]) {

int i = 10 – 2 / 5 * 10 / 2 – 1;

printf("%d",i);

return 0;

}

Choose the right answer:
A . The program outputs 0
B . The program outputs 4
C . Compilation fails
D . The program outputs 9
E . The program outputs 15

Answer: D

Explanation:

The expression 10 – 2 / 5 * 10 / 2 – 1 is evaluated based on the standard precedence rules in

C. Division and multiplication have higher precedence than addition and subtrac-tion, and they are evaluated from left to right:

Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments