Program:
#include <bits/stdc++.h>
using namespace std;
int main()
{
string s = "abcd";
cout << "Substrings are: << endl;
for(int i = 0; i < s.size(); i++)
{
for(int j = i; j < s.size(); j++)
{
for(int k = i; k <= j; k++)
cout << s[k];
cout << endl;
}
}
return 0;
}
Output:
Substrings are:
a
ab
abc
abcd
b
bc
bcd
c
cd
d
C++ Program To Print All Sub Strings Of A String.
Reviewed by Beast Coder
on
May 14, 2021
Rating:
No comments: