Aspire's Library

A Place for Latest Exam wise Questions, Videos, Previous Year Papers,
Study Stuff for MCA Examinations - NIMCET

Previous Year Question (PYQs)



Given

int arr[3][4][2] =
{
  {{2,4},{7,8},{3,4},{5,6}},
  {{7,6},{3,4},{5,3},{2,3}},
  {{8,9},{7,2},{3,4},{5,1}}
};

Which one of the following can be used to refer to element 1 in the above 3-d array?






Solution

In C language, array indexing starts from $0$.

The element $1$ is present at:

$arr[2][3][1]$

Now,

$arr+2$ points to the third $2$-D block.

$*(arr+2)$ gives $arr[2]$.

$*(arr+2)+3$ points to $arr[2][3]$.

$*(*(arr+2)+3)$ gives $arr[2][3]$.

$*(*(arr+2)+3)+1$ points to $arr[2][3][1]$.

Therefore,

$*(*(*(arr+2)+3)+1)=arr[2][3][1]=1$



Online Test Series,
Information About Examination,
Syllabus, Notification
and More.

Click Here to
View More


Online Test Series,
Information About Examination,
Syllabus, Notification
and More.

Click Here to
View More

Ask Your Question or Put Your Review.

loading...