LearnFrenzy
Sign in Take a free test

Operators and Expressions · Predict the Output · Question 2

10 - 4 - 3 * 2 + 8 / 4 % 3 – output Answer, explanation & discussion

  • Output
  • Medium
  • 0 comments
  • Answer explained
  • Moderated community
Question 2 Back to Exercise

What is the output of the following C program?

main.c
#include <stdio.h>

int main(void) {
    printf("%d\n", 10 - 4 - 3 * 2 + 8 / 4 % 3);
    return 0;
}
  • A 2 Correct
  • B 0
  • C 4
  • D -2
Correct Answer: Option A

* / % first, left to right: 3 × 2 = 6, 8 / 4 = 2, 2 % 3 = 2. Then + - left to right: 10 − 4 − 6 + 2 = 2.

Discussion & Comments 0

Share your method, a shortcut, or ask about a step you didn't follow.

No comments yet. Be the first to share your solution!

Post your comment

Comments appear after a quick review by our team.

Search LearnFrenzy

Esc

Quick links