GATE | GATE CS 2019 | Question 33
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; } |
chevron_right
filter_none
The number that will be displayed on execution of the program is _________ .
(A) 6
(B) 5
(C) 4
(D) segmentation error
Answer: (A)
Explanation:
#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; } |
chevron_right
filter_none
Note that index of array always start from 0 in C.

Initially ip pointer is pointing at (arr+4) or skipping starting first 4 position.

Now in the printf system call, 1 more position is to skip, So it will point to (arr+5) or skip 5 position from starting:
Hence, printf will print value at 6th position, i.e., 6 will printed.
So, option (A) is correct.
Quiz of this Question
Recommended Posts:
- GATE | GATE CS 1999 | Question 36
- GATE | GATE CS Mock 2018 | Question 39
- Top 5 Topics for Each Section of GATE CS Syllabus
- How to prepare in Last 10 days to score high in GATE?
- Aptitude | GATE IT 2006 | Question 7
- Aptitude | GATE IT 2006 | Question 8
- GATE | GATE CS 2013 | Question 1
- GATE | GATE CS 2013 | Question 3
- GATE | GATE CS 2013 | Question 4
- GATE | GATE CS 2013 | Question 65
- GATE | GATE CS 2013 | Question 6
- GATE | GATE CS 2013 | Question 7
- GATE | GATE CS 2013 | Question 8
- GATE | GATE CS 2013 | Question 65
- GATE | GATE CS 2013 | Question 65



