GATE 2019 CS – Question 34
Consider the following C program:
#include <stdio.h>
int main(){
int arr[]={1,2,3,4,5,6,7,8,9,0,1,2,5}, *ip=arr+4;
printf("%d\n", ip[1]);
return 0;
}The number that will be displayed on execution of the program is ________.
Practise this question in The GATE Grind →
Show answer and explanation
Correct answer: 6
Explanation
`arr` is an `int` array and `ip = arr + 4` points to `arr[4]` (the value 5).
`ip[1]` is `*(ip+1)`, i.e. `arr[5]`.
`arr = {1,2,3,4,5,6,7,8,9,0,1,2,5}`, so `arr[5]=6`. The program prints **6**.