Computer Sciences > GATE 2026 SET-2 > Programming and Data Structures
Consider the following ANSI-C program.
The output of this program is ____________. (answer in integer)
Note: Assume that the program compiles and runs successfully.

Correct : 9

Explanation:
1. int *ptr, a, b, c; (Declares variables)
2. a=5; b=11; c=20; (Initial values set)
3. ptr=&a; (ptr points to a)
4. *ptr=c; (Value of a becomes equal to c, so a = 20)
5. ptr=&c; (ptr now points to c)
6. a=*(&b); (Value of a becomes equal to b, so a = 11)
7. c=*ptr-a; (Since ptr points to c, *ptr is 20. Thus, c = 20 - 11 = 9)
8. printf("%d",c); (Outputs 9)

Similar Questions

In C runtime environment, which one of the following is stored in heap?
#1562 MCQ
Consider the following three ANSI-C programs, P1, P2 and P3Which one of the following statements is true?
#1564 MCQ
Consider the following ANSI-C function. The maximum possible value that can be returned from this function is ____________. (answer in integer) Note: Ig...
#1607 Fill in the Blanks

Related Topics

GATE 2026 GATE CS 2026 Set 2 GATE CS 2026 Q60 ANSI C program GATE pointer in C GATE output of C program GATE pointer dereference GATE GATE NAT question C programming GATE 2026 GATE CS pointers question *ptr assignment GATE address of operator GATE

Unique Visitor Count

Total Unique Visitors

Loading......