Consider the following ANSI-C program.
2026
Consider the following ANSI-C program.

Attempted by 21 students.
Show answer & explanation
Correct answer: 9
Code Execution Trace
1. Initialization: a = 5, b = 11, c = 20.
2. ptr = &a; The pointer ptr now holds the address of variable a.
3. *ptr = c; Since ptr points to a, this updates a to the value of c (20). Now a = 20.
4. ptr = &c; The pointer ptr is updated to hold the address of variable c.
5. a = *(&b); The address of b is taken and dereferenced, assigning the value of b (11) to a. Now a = 11.
6. c = *ptr - a; ptr points to c, so *ptr is 20. a is 11. Calculation: c = 20 - 11 = 9.
7. printf("%d", c); The program prints the final value of c, which is 9.