C++ Programming Code Examples C++ > Strings Code Examples Programming Code to Reverse String Programming Code to Reverse String To reverse a string in C++ programming, then ask to the user to enter a string, now make a variable say temp of char type and start swapping. Place first character of the string in temp and last character of the string in the first, then place temp in the last and continue, to swap string as shown in the following program. Following C++ program ask to the user to enter a string to reverse it and display the reversed string on the screen: #include<iostream.h> #include<conio.h> #include<stdio.h> void main() { clrscr(); char str[100], temp; int i=0, j; cout<<"Enter the String : "; gets(str); i=0; j=strlen(str)-1; while(i<j) { temp=str[i]; str[i]=str[j]; str[j]=temp; i++; j--; } cout<<"Reverse of the String = "<<str; getch(); }