Check out example codes for "print subsets of an array". It will help you in understanding the concepts better.

Code Example 1

#include <iostream>
using namespace std;
void printSubset(int arr[], int n, int r, int index, int data[], int i);
int main(){
   int arr[] = {3 , 5, 6};
   int r = 2;
   cout<<"The sets are : ";
   int n = sizeof(arr) / sizeof(arr[0]);
   int data[r];
   printSubset(arr, n, r, 0, data, 0);
   return 0;
}
void printSubset(int arr[], int n, int r, int index, int data[], int i){
   if (index == r) {
      for (int j = 0; j < r; j++)
         cout<<data[j]<<" ";
      cout<<endl;
      return;
   }
   if (i >= n)
      return;
   data[index] = arr[i];
   printSubset(arr, n, r, index + 1, data, i + 1);
   printSubset(arr, n, r, index, data, i + 1);
}

Learn ReactJs, React Native from akashmittal.com