reverse string recursion

 #include <iostream>

#include <string>


using namespace std;


void reverse(string s){

    if(s.length()==0){

        return;

    }

    string ros=s.substr(1);

    reverse(ros);

    cout<<s[0];

}


int main() {

    

    string s="binod";

    reverse(s);


    return 0;

}

Comments

Popular posts from this blog

Sum of Even Numbers till N

Find the Runner-Up Score!

Print All Substrings