title: Combination of unique elements without repetition
body: <p>Elements : a b c
  all combinations in such a way:<br>a<br>b<br>c<br>ab<br>ac<br>bc<br>abc</p>
  
  <p>Formula to get total number of combinations of unique elements without repetition = 2^n - 1 (where n is the number of unique elements)<br>
  In our case top: 2^3 - 1 = 7
  <br><br>Another formula to get the combinations with specific length = n!/(r! * (n - r)!) (where n= nb of unique items and r=length)
  <br>
  Example for our the above case with r=2 : 3!/(2! * 1!) = 3 which is ab ac bc
  <br></p>
  
  <p>Is there any algorithm or function that gets all of the 7 combinations?
  I searched a lot but all i can find is one that gets the combinations with specific length only.<br><br>
  <strong>UPDATE:</strong><br>
  This is what I have so far but it only gets combination with specific length:<br></p>
  
  <pre><code>void recur(string arr[], string out, int i, int n, int k, bool &amp;flag)
  {
      flag = 1;
      // invalid input
      if (k &gt; n)
          return;
  
      // base case: combination size is k
      if (k == 0) {
          flag = 0;
          cout &lt;&lt; out &lt;&lt; endl;
          return;
      }
  
      // start from next index till last index
      for (int j = i; j &lt; n; j++)
      {
          recur(arr, out + " " + arr[j], j + 1, n, k - 1,flag);
      }
  }
  </code></pre>