in Programming in C retagged by
410 views
6 votes
6 votes

What will be the output of the following program?

main()
{
    int a[2][2] = { {1,2},{3,4} };
    int(*p)[2][2];
    p = &a;
    printf("%d", (*p)[0][0]);
}
  1. $1$
  2. $3$
  3. $4$
  4. None of these
in Programming in C retagged by
410 views

1 Answer

3 votes
3 votes

$a$ is an int array of size $2 \times 2.$

$p$ is a pointer to $\textsf{int}$ array of size $2 \times 2.$

$p = \&a \rightarrow p$ points to array $a.$ Thus, $a$ and $*p$ are now equivalent.

(*p)[0][0] ≣ a[0][0]

Answer:- A

edited by