The program to reverse a given string takes input string and output reverse of the string. This is program is a simple C program intended for beginners of C language.
The program is written and compiled using Dev-C++ compiler on a windows 7 64-bit system. You can use any other standard C compiler to compile and run the program.
To help you learn this program we have following section – Problem Definition, Flowchart , Source Code for the program and verified Output.
The program takes an input string at run-time using the builtin function gets( str ) where str is a character array. In this array of characters, the beginning characters are exchanged with the ending characters of the string with the help of a temp variable.
If the string is “ELEPHANT”
The letter is ‘E’ and ‘T’ are exchanged until all characters are reversed. The final output is TNAHPELE.
C program to reverse a string
Output – Reverse the String