About the reverse function

i want to ask that in program when we write
reverse (a[i],a[i]+n)
how (a[i]+n) is 4 as we know that a[i] is 1 in that problem and n=4;

hello @manoj2597

its a 2d matrix .
here a[i] will not give u element value.
instead it will return starting address of ith row (row counting from 0)
so a[i] is starting adress of ith row and a[i]+4 is ending address(adress next to last element of ith row).

but how it is returning address. please elaborate it

and in this problem u also tell how reverse (a[1],a[1]+n) reverse 2 by 3

read about reverse function , it will not only reverse two element instead it will reverse the complete array.
a[1],a[1+n] will reverse the complete row one.
if initially it is [1,2,3,4] then it will become [4,3,2,1]

to understand this read how 2d matrix is stored in memory (row major /colum major).
and how address of any cell of that matrix is calculated (to understand this u should know pointers in depth).

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.