LearnFrenzy
Sign in Take a free test

Operators and Expressions · Predict the Output · Question 1

b = a++ * 2 – output Answer, explanation & discussion

  • Output
  • Easy
  • 0 comments
  • Answer explained
  • Moderated community
Question 1 Back to Exercise

What is the output of the following C program?

main.c
#include <stdio.h>

int main(void) {
    int a = 5, b;
    b = a++ * 2;
    printf("%d %d\n", a, b);
    return 0;
}
  • A 6 10 Correct
  • B 6 12
  • C 5 10
  • D 6 11
Correct Answer: Option A

a++ supplies the old value 5 to the multiplication, so b = 10; a becomes 6 afterwards.

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