C++ program to reverse a given string using predefined methods
kw.cpp
#include<iostream>
#include<bits/stdc++.h>usingnamespacestd;intmain(){cout<<"———————————————————————————————————————————";cout<<"\nProgram to reverse a given string";cout<<"\n———————————————————————————————————————————";strings;cout<<"\nEnter the string ";getline(cin,s);reverse(s.begin(),s.end());cout<<"\nThe reverse string is "<<s;cout<<"\n———————————————————————————————————————————\n";}
Output
kodingwindow@kw:~$ g++ kw.cpp kodingwindow@kw:~$ ./a.out
———————————————————————————————————————————
Program to reverse a given string
———————————————————————————————————————————
Enter the string Hello, World!
The reverse string is !dlroW ,olleH
———————————————————————————————————————————
kodingwindow@kw:~$
Dear User, Thank you for visitng KodingWindow. If you are interested in technical articles, latest technologies, and our journey further, please follow us on LinkedIn.