Reverse function in STL


why am i not getting reversed vector though i am using reverse function

hello @dare_devil_007
it will work.
reverse(v.begin() + start_index, v.begin() + end_index+1 );
this is the syntax you should follow to reverse vector v from index = start_index to index=end_index.

note-> indexing is 0 based.

can you pls correct my code and send the link

yeah sure,
what exacly u want,
do u want to reverse array from index s to e.
or from s-1 to e-1.

it would be helpful if u demonstrate them both


intially our array was.
index->0 1 2 3
array ->5 2 5 1
now we perform reverse operation from index 1 2
our array will become
index->0 1 2 3
array ->5 5 2 1
now we again perform reverse operation from index 1 to 1.
our array will become
index->0 1 2 3
array ->5 5 2 1

so resultant array after both the operation will be
index->0 1 2 3
array ->5 5 2 1

ur code is also producing the same.
image

ur updated code ->

thanks a lot man!! i got it now