Coders Packet

C++ program to generate all subsets of a String

By Aalok Kumar

Hey Developers, I have written a C++ program to generate all the possible subsets of a String.

In this program, the function gen_Subsets(string str) takes string str of length n as an argument.

This function prints all subsets of the string str in a separate line.

Here is the sample output of my program:

Enter a string: ab
OUTPUT:
a 
b 
a b 

Enter a string: abc
OUTPUT:
a 
b 
a b 
c 
a c 
b c 
a b c 

Enter a string: abcd
OUTPUT:
a 
b 
a b 
c 
a c 
b c 
a b c 
d 
a d 
b d 
a b d 
c d 
a c d 
b c d 
a b c d

Enter a string: 123
OUTPUT:
1 
2 
1 2 
3 
1 3 
2 3 
1 2 3 

 

 

Download project

Reviews Report

Submitted by Aalok Kumar (Aaloks766626)

Download packets of source code on Coders Packet