C Program to Reverse String Without Using Library Function

Program : Reverse String Without Using Library Function [ Strrev ]

Output :

Explanation Of Program :

Firstly find the length of the string using library function strlen().

Suppose we accepted String “Pritesh” then –

As we know String is charracter array and Character array have character range between 0 to length-1. Thus we have position of last character in variable ‘j’.Current Values of ‘i’ and ‘j’ are –

‘i’ positioned on first character and ‘j’ positioned on last character. Now we are swapping characters at position ‘i’ and ‘j’. After interchanging characters we are incrementing value of ‘i’ and decrementing value of ‘j’.

If i crosses j then process of interchanging character is stopped. Refer this link to view Slide Show to Know Reversing procedure of String.