in Programming in C
1,430 views
3 votes
3 votes
main( )
{
int n[3][3] = {
2, 4, 3,
6, 8, 5,
3, 5, 1
} ;
printf ( "\n%d %d %d", *n, n[3][3], n[2][2] ) ;
}
in Programming in C
1.4k views

4 Comments

@Hemant 

the first element is " *n " so it should give the value of the 1st element of the array. If only " n " will be there then it will print its address! 

Tell me If I am wrong! 

Thanks in advance.

0
0

I am getting garbage, garbage, 1.

0
0
remember this when we say 'n' it is '&n'

'n[i]' is equivalent to '  *(n +i ) '     reference : yashavant kanetkar

in the case of 1D array if we say *n  -> *(n+0)  -> n[0] which is an integer then we can get the value

 in that place

in the case of 2D array if we say *n -> n[0] in the case of 2D array it is still an array so we get the

 adress of the first 1D array so we'll dereference it again this time we get the value of the integer

 stored in [0][0]

i don't know to what extent i am correct

the main observation i observed is if n[i] is an integer we can get that

if n[i] is an array we get the adress of the array
0
0

1 Answer

0 votes
0 votes
2, garbage, 1

2 Comments

it is *n, which will return address,

if it would be **n, then the first value printed would be 2

0
0
Ohk. Got it! Thank you :)
0
0

Related questions