String Based Question in Video

How is the code for reversal == true written why we are looping till n/2 and what we are swapping if reversal is true. And here is the code of the question don’t know where it is going wrong?https://ide.codingblocks.com/

Hey @Sakshi2004
basically we are reversing it there

Let me explain u with an example of string
say
abcd
So to reverse it we can swap a,d and b,c
so it will become dcba
see it got reversed
I hope this helped :slight_smile:

Yes . Got your explanation but here in the string question what we are supposed to do if reversal is given to be true? Do we have to reverse the all the string entered?

You have to reverse the output u were printing
say reversal was false and u were printing
A
B
C
then with reversal as true u will print
C
B
A
i.e order of output will be reversed

In the lecture sir reversed an array of pairs
not a particular string

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.