Skip to main content

GATE CSE 2026Programming in C › Pointers, Arrays & StringsVerified

GATE CSE 2026 PYQ: Consider the following ANSI-C program. #include <stdio.h> int main (){ int * ptr , a , b , c ; a = 5 ; b =…

Consider the following ANSI-C program.

  1. #include <stdio.h>
  2. int main(){
  3. int *ptr, a, b, c;
  4. a=5; b=11; c=20;
  5. ptr=&a; *ptr=c; ptr=&c;
  6. a=*(&b); c=*ptr-a;
  7. printf("%d",c);
  8. return(0);
  9. }

The output of this program is ____\_\_\_\_ . (answer in integer)

Note: Assume that the program compiles and runs successfully.

    Answer

    9

    Approach

    Trace the C program statement by statement, keeping track of the values of variables and the target of the pointer.

    After the assignments, the final value of c is 20 - 11 = 9, and that value is printed.

    Reviewed by GateIQ Editorial Team: IIT & IISc Alumni.