Write a Program in C++ & Python to Reverse a String

By | August 27, 2019

In this program, we will ask the user to enter a string and print out that string in reverse order.

C++ program to reverse a string:

void main() {
     char ch[50];
     cout<<"Enter a String: ";
     cout<<"The reverse string is: ";
     for(int i=strlen(ch); i >= 0;i--)


Enter a String: tech
The reverse string is: hcet

Python program to reverse a string:

ch= input("Enter a String: ")
print("The reverse string is:",ch[::-1])


Enter a String: techgeekbuzz
The reverse string is: zzubkeeghcet

Leave a Reply

Your email address will not be published. Required fields are marked *