Reagardin pointeas and arrays

for
int a[]={1,2,3,4};
cout<<&(a+1);
why it sowing error not address of 2

Hello @Namanjain123,

the name of array act as pointer to the first element of the array i.e. a[0].
So, cout<<a; will give the address of a.

Now, a+1 indicates the address of a[1] and
a+2 indicates the address of a[2] and so on.

So, if you have to print the address of 2, then you have to write the statement cout<<a+1;
and to see the value at the address, cout<<*(a+1);

Thus, doing cout<<&(a+1); throws an error as a+1 is itself an address.

Hope, this would help.
Give a like, if you are satisfied.