Question: I'm having a very hard time understanding recursion. Can someone explain to me how this code works. I added some cout statements to try to
I'm having a very hard time understanding recursion. Can someone explain to me how this code works. I added some cout statements to try to understand whats going on but it only made me more confuse, I understand from abcdef to fe but after that I'm totally lost.
#include
using namespace std;
string reverseMe(string x){
if (x.length() == 1) {
}
else{
cout
cout
x= reverseMe(x.substr(1,x.length()-1)) + x.at(0);
cout
cout
}
return x;
}
int main() {
string tmp;
cout
getline(cin, tmp);
tmp = reverseMe(tmp);
cout
}

Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
