Write the program to make substring of a string.


#include
<iostream>

#include<string>

using namespace std;

  void substring(string a,string ans)
  { if (a.size()==0)
       {cout<<ans <<endl;
     return;}
     char c=a[0];
     string ros=a.substr(1);
     substring(ros,ans);
     substring(ros ,ans+c);
    }

  int main()
{
    string a ="ABC";
    string b ="";
    
    substring(a,b);
   
    return 0;
}

Comments

Popular posts from this blog

SCHOLARSHIP

Write a c++ program to display numbers which is divisible by 2 as well 3 from 6 to n by using and operator .

Write a program to add natural numbers up to 20 by using for loop in c++ language.