GateAI
Programming in C

GATE CSE 2019 · Q24

NAT1 markEasy

Time

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 ", ip[1]); return 0; }The number that will be displayed on execution of the program is _______.

Your answerNumerical answer

Enter a value to check

Solution

Step-by-step verified solution

Official answer: 6 (±0)

Programming in C

Given 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):

ip[1]=∗(arr+4+1)=∗(arr+5)=arr[5]=6\text{ip}[1] = *(\text{arr} + 4 + 1) = *(\text{arr} + 5) = \text{arr}[5] = 6

Thus, the printed number is 6.

Try the question first, then check your work.

Think the official key or this write-up is wrong?

Report error or challenge

Examiner trap

The misconception this question tests

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

Where do you stand for GATE?

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.

One GATE CSE PYQ every morning

An official question by email at 7 AM IST, with a link to its verified solution. Unsubscribe in one click.

Programming in C in GATE CSE

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 C

More from GATE CSE 2019

Share this solution

A plain-text card for WhatsApp or Telegram study groups.

GateAI solution cardGATE CSE 2019 · Q24 · NAT

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

Independent practice explanation verified by the GateAI team. GATE is conducted by the IITs; question text follows the official paper.