GATE 2025 CS (CS1) – Question 34
#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;
}The output of the given C program is __________. (Answer in integer)
Practise this question in The GATE Grind →
Show answer and explanation
Correct answer: 25
Explanation
z points to a, and foo writes x=25 through the pointer, so a becomes 25.