146 views
give the complete solution with explanation

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

}

edited | 146 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 so first a land you to the matrix {5,6,7,8} now you need to choose a 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 vote
Ans will be

*p = 8

*q = 10

for clear idea, your array can be seen as

arr            arr

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

p = &arr  

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.