GATE 2014 CS (CS1) – Question 20
Consider this C program:
#include <stdio.h>
main() {
int i;
int *pi = &i;
scanf("%d", pi);
printf("%d\n", i+5);
}
Which statement is TRUE?
Practise this question in The GATE Grind →
Show answer and explanation
Correct answer: (D) The printed value is 5 more than the integer entered.
Explanation
pi holds the address of i, so scanf with pi stores the entered integer into i. The printf argument is i+5, giving **five more than the entered integer, D**. It does not print pointer arithmetic. This uses the source’s historical C dialect allowing the implicit-int main declaration.