GATE CS 2025 Set 1 | Question 34
Programming & Data Structures › Pointers · NAT · 1 mark · Answer: 25
- Question 34Programming & Data Structuresnat1 markConsider the C program:
The output of the given C program is __________. (Answer in integer)#include <stdio.h> void foo(int *p, int x){ *p = x; } int main(){ int *z; int a = 20, b = 25; z = &a; foo(z, b); printf("%d", a); return 0; }Answer: 25
Solution
Answer: 25zpoints toa. The callfoo(z, b)passes this pointer and the valueb = 25. Insidefoo,*p = xwrites25through the pointer, i.e. intoa. Soabecomes25, andprintf("%d", a)prints .
More GATE PYQ on Pointers
All GATE CS Programming & Data Structures PYQ →Attempt GATE CS 2025 Set 1 in real GATE exam mode
Full paper with a timer, the GATE interface and a topic-wise analysis — free.
Create free account →