In this program, we will ask the user to enter a string and print out that string in reverse order.
Program to reverse a string in C++
#include<iostream.h>
#include<conio.h>
#include<string.h>
void main() {
clrscr();
char ch[50];
cout<<"Enter a String: ";
cin>>ch;
cout<<"The reverse string is: ";
for(int i=strlen(ch); i >= 0;i--)
cout<<ch[i];
getch();
}
Output:
Enter a String: tech
The reverse string is: hcet
Program to reverse a string in Puthon:
ch= input("Enter a String: ")
print("The reverse string is:",ch[::-1])
Output:
Enter a String: techgeekbuzz
The reverse string is: zzubkeeghcet
People are also reading:
- Python Program to Check Armstrong Number
- WAP to convert a lowercase alphabet to uppercase or vice-versa using ASCII code
- Python Program to Display the Multiplication Table
- WAP to Find Cube of a Number using Functions
- Python Program to Count the Number of Each Vowel
- WAP to print given series:1 2 4 8 16 32 64 128
- Python Program to Convert Decimal to Binary Using Recursion
- WAP to print the truth table for XY+Z
Leave a Comment on this Post