Question discussion

What is the output of the following C program?#include int main() { int a = 5; int b = a++ + 10; int c = ++a * 2; printf("%d %d %d", a, b,…

1112Medium DSSSB TGT Computer Science 0 replies 1 views
0

What is the output of the following C program?

#include <stdio.h>
int main() {
    int a = 5;
    int b = a++ + 10;
    int c = ++a * 2;
    printf("%d %d %d", a, b, c);
    return 0;
}
  • A6 15 12
  • B7 16 14
  • C7 15 14
  • D7 15 12
Correct answer: C

Explanation

b = 5 + 10 = 15 and a becomes 6; ++a makes a = 7 so c = 14.

Discussion 0

Nobody has replied yet. Start the discussion!