All mock tests are FREE till 31 December — register to save your progress

What will be the output of the following C programming code:
void main()
{
  int *i, a=12, b=2, c;
  c = (a=a+b, b=a/b, a=a*b, b=a-b);
  i = &c;
  printf("%d", --(*i));
}

Pick an option to check yourself, or open the answer below.

Show answer & explanation

Correct answer: B. 90

Explanation

The comma operator evaluates left to right and yields the last value: a = 14, b = 14/2 = 7, a = 14×7 = 98, b = 98 − 7 = 91, so c = 91. --(*i) pre-decrements c to 90 and prints 90.

More Programming Languages and Computer Graphics questions