The Gateway to Computer Science Excellence
First time here? Checkout the FAQ!
x
0 votes
136 views
give the complete solution with explanation

int main()
{
    int arr [2] [2] [2] = {10,2,3,4,5,6,7,8};
    int *p, *q;
    p = &arr[1] [1] [1];
    q = (int*) arr;
    printf("%d ,%d \n",*p ,*q);
    return 0;

}
in Programming by (31 points)
edited by | 136 views
0
8 and 10
0

@shivam sharma 5

don't miss use the tags.... you can include your requirement either in your question or comment

0
please provide the stepwise solution so that it can be easy to understand
0
a[1][1][1] so first a[1] land you to the matrix {5,6,7,8} now you need to choose a[1][1] of this matrix so it will be 8 and  and  when we assign the array name to a pointer we give the base address to it so *q will give 10 hence result will be 8 10

1 Answer

+1 vote
Ans will be

*p = 8

*q = 10

for clear idea, your array can be seen as

arr[0]            arr[1]

$\begin{bmatrix} 10 & 2\\ 3& 4 \end{bmatrix}$   $\begin{bmatrix} 5 & 6\\ 7& 8 \end{bmatrix}$
by (249 points)
0

 p = &arr[1] [1] [1]

p holds the address of the element at 1th column of 1th row of 1th 2-D array.

1th 2-D matrix is $\begin{pmatrix} 5 &6 \\ 7 &8 \end{pmatrix}$

Then 1th row is [7 8]

Element at 1th colum is 8.

So p holds the address of  8 and *p gives value at that address which is 8.

q holds the base address of the 3-D array type casted to (int *) as q is a pointer to an integer type. The element at the base is 10(i.e. the first element). So *q gives 10. 

Related questions

+1 vote
2 answers
3
Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true
50,092 questions
55,276 answers
190,804 comments
86,089 users