MTH 181
Extra Credit:
Subsets of a Set Program
Fall 2016
Write a program that prints all the subsets B of a set A where ! 0 ≤ B ≤ A ≤ 10
Details: Your program should
a) Prompt the user to enter ! n = A where ! 0 ≤ n ≤ 10 , then
b) Prompt the user to enter the word “All” in which case your program should print all the
subsets of A or enter ! k = B , where ! 0 ≤ k ≤ 10 , in which case your program should
print all the subsets of size ! B or a message saying that none exist.
The set ! A consists of the first n-letters of the alphabet. Each subset should be printed on a
different line.
Example 1: If ! n = A = 3 and the user enters “All” then the output of your program should be
All the subsets of A = {a, b, c} are
1. {}
2. {a}
3. {b}
4. {a, b}
5. {c}
6. {a, c}
7. {b, c}
8. {a, b, c}
Example 2: If ! n = A = 3 and ! k = B = 2 then the output of your program should be
The
1.
2.
3.
subsets B of A = {a, b, c} with |B| = 2 are
{a, b}
{a, c}
{b, c}
You can use any standard programming language including Basic, Pascal C/C++, FORTRAN,
Java, Javascript, or Python. However, you can only use standard libraries! Send me your source
code via email.
© Copyright 2026 Paperzz