Program:
#include <iostream>>
using namespace std;
void reverse(string s)
{
if(s.size() == 0)
return;
string ros = s.substr(1);
reverse(ros); //recursive calling function reverse
cout << s[0];
}
int main()
{
string s = "ninety";
reverse(s); //fuction call
return 0;
}
Output:
ytenin
See more programs of strings here.
C++ Program To Find Reverse Of a String Using Recursion
Reviewed by Beast Coder
on
March 31, 2021
Rating:
No comments: