Consider the following C program: #include int main(){ int arr[]={1,2,3,4,5,6,7,8,9,0,1,2,5}, *ip=arr+4; printf("%d ", ip[1]); return 0; } The number that will be displayed on execution of the program is …
Topic-wise GATE CS PYQs with verified steps
GATE CSE 2019 · Q24
Time
#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
", ip[1]);
return 0;
}The number that will be displayed on execution of the program is _______.Your answerNumerical answer
Solution
Official answer: 6 (±0)
Programming in CGiven array:
arr = {1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 5}
Indices:
arr[0] = 1
arr[1] = 2
arr[2] = 3
arr[3] = 4
arr[4] = 5
arr[5] = 6
The pointer ip is initialized to arr + 4, which points to arr[4] (the element 5).
The expression ip[1] evaluates to *(ip + 1):
Thus, the printed number is 6.
Try the question first, then check your work.
Examiner trap
Remember that pointer indexing ip[1] is equivalent to *(ip + 1).
This Programming in C previous year question is Q24 of the GATE CSE 2019 paper. Find more GATE CSE PYQs on Programming in C in Programming and Data Structures, or browse all GATE CSE PYQs.
Free diagnostic
Take the 20-minute diagnostic: the 3 topics that cost you the most marks, and a rank range. Or sit 5 related Programming in C PYQs now with no account.
An official question by email at 7 AM IST, with a link to its verified solution. Unsubscribe in one click.
Programming in C has 74 GATE CSE PYQs across 25 papers from 2011 to 2026. 16 of them are 1-mark NAT questions like this one, and GATE CSE 2019 has 3.
How GATE tests Programming in CIndependent practice explanation verified by the GateAI team. GATE is conducted by the IITs; question text follows the official paper.