2D Arrays and strings


can you please explain me its output?

Sure @nirupama1,

Let’s understand the entire concept from basics:

What is an array?
Homogeneous continuous allocation of memory
Homogeneous indicates that it can store values of same datatype.

So, when you define an array:
int a[3]={1,2,3};
cout<<a[0]; //Print the element at index 0 i.e. 1
cout<<a; //Prints the base or starting address of the array.
NOTE:
Here the name of the array act as a pointer to the first element of the array.

What is 2D-array?
In simple words, we can say it is an array of array. Correct?
So, when you define a 2D array:
int a[][3]={{1,2,3},{4,5,6}};
Here, each row is a separate array.
cout<<a; //Print the element at index 0 i.e. 1
cout<<a[0]; //Prints the base or starting address of the array in the 0th row(i.e. the first row)
and cout<<a[0][0]; //Prints the first element of the first row.
or you can use the following statement for the same:
cout<<*a[0]; //as a[0] is a pointer to the starting element of the array in the first row.
Similarly, a[1]; is a pointer to the starting element of the array in the second row.

I am considering that you have clearly understood the concept of the pointer.
If not, then do it as it is going to play a major role in the rest of the course.

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