You can represent a subset of elements using an integer. Each bit position corresponds to one element: bit is 1 if element is in the subset, 0 otherwise.
For example, with 4 elements , the number represents the subset (bits 0 and 2 are set).
With elements, there are possible subsets (each element is either in or out). You can iterate through all subsets by looping from to and treating each number as a bitmask.