C++ program to print all possible subsets of a String














































C++ program to print all possible subsets of a String



#include<bits/stdc++.h>
using namespace std;
//printing all the substrings
void substring(char str[], int n){
    int len,j,i,k;
   for ( len = 1; len <= n; len++){
      for ( i = 0; i <= n - len; i++){
         j = i + len - 1;
         for ( k = i; k <= j; k++)
         cout << str[k];
         cout << endl;
      }
   }
}
int main(){
   char str[100] ;
   cout<<"enter a string"<<endl;
   cin>>str;
   cout<<"The substrings are"<<endl;
   substring(str, strlen(str));
   return 0;
}
Output:
enter a string
abcd
The substrings are
a
b
c
d
ab
bc
cd
abc
bcd
abcd



More Articles of Shaik Aftab Ahmed:

Name Views Likes
C++ Program to Find the Frequency of Odd & Even Numbers in the given Matrix 311 1
C++ program to Sort a Linked List Using Merge Sort 282 1
C++ Program to Implement a Linked List representation of a Binary tree 268 1
C++ Program to Check for balanced parentheses in an expression 182 1
C++ Program to Perform Inorder, Preorder, Postorder traversals in a binary tree. 229 1
C++ program to print Indian flag 268 1
C++ program to Convert a multi level linked list to a singly linked list 181 1
C++ program to print right view of a Binary tree using queue 197 1
C++ Program to implement Huffman Coding Compression Algorithm 822 1
C++ Program to Create a Height Balanced Binary Tree 213 1
C++ program to implement Prims algorithm 310 1
C++ Program for BFS Traversal 217 1
C++ Progam to Evaluate a Prefix Expression 205 1
C++ Program to Implement Queue using Linked List 210 1
C++ implementation of Stack using Linked list 227 1
C++ program to find the intersection point of two linked lists 256 1
C++ program to count the inversions in the given array 236 1
C++ program to perform D.N.F sort 276 1
C++ program to print all possible subsets of a String 249 1
C++ program to count the number of ones in a binary representation of a number 256 1
C++ program to print all possible subsets of a set 280 1
C++ program to find the largest word in a String 241 1
C++ Program to print a matrix in Spiral order 278 1
C++ program to convert from Binary to Decimal, Octal to Decimal, Hexadecimal to Decimal 266 1
C limits library 298 1
Program to add two Binary numbers 269 1

Comments