What will be the output of the following C Programming code: Void main() { Int…

2025

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));
}

  1. A.

    91

  2. B.

    90

  3. C.

    98

  4. D.

    92

Attempted by 177 students.

Show answer & explanation

Correct answer: B

Step-by-step evaluation of c = (a = a + b, b = a / b, a = a * b, b = a - b):

  • Start with a = 12, b = 2.

  • a = a + b => a becomes 14.

  • b = a / b => b becomes 14 / 2 = 7.

  • a = a * b => a becomes 14 * 7 = 98.

  • b = a - b => b becomes 98 - 7 = 91.

The comma operator yields the value of the last expression, so c is assigned 91.

i points to c. The expression --(*i) pre-decrements c to 90 and that decremented value (90) is printed.

Final output: 90

A video solution is available for this question — log in and enroll to watch it.

Explore the full course: Mppsc Assistant Professor