The Gateway to Computer Science Excellence
+1 vote
256 views
main()
 {
     int arr2D[3][3];
     printf("%d\n", ((arr2D==* arr2D)&&(* arr2D == arr2D[0])) );
 }
in Puzzles by Loyal (7.9k points) | 256 views

1 Answer

+3 votes
Best answer
 

The name arr2D refers to the beginning of all the 3 arrays containing 3 integer each.

*arr2D refers to the start of the first 1D array (of 3 integers) that is the same address as arr2D.

So the expression (arr2D == *arr2D) is true (1).

Similarly, *arr2D is nothing but *(arr2D + 0). Again arr2D[0] is the another way of writing *(arr2D + 0).

So the expression (*(arr2D + 0) == arr2D[0]) is true (1). 

Ans- 1 && 1 = 1

by Boss (26.4k points)
selected by
0

The name arr2D refers to the beginning of all the 3 arrays containing 3 integer each.  ?

what is the meaning here

0
Means the name arr2D is pointing to the base address of 2-D array.
0

how is this expression (arr2D == *arr2D)  true

arr2D gives the base address of the array whereas *arr2D gives the value at the base address since we can write it as *(arr2D+0) 

0

1st statement should be false..

arr2D is an address( we know array name is mnemonic for address, here it represent base address) and *aar2D is a pointer to array because of deferencing it will contain value inside the address...so both should not be equal ryt???

0

arr2D contains address *arr2D points first  elem location's singledim sub array so both are same

Related questions

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,645 questions
56,588 answers
195,788 comments
101,845 users