//C program to print sum of
//all subsets
#include <stdio.h>

//Function to print sum of subset
//Using Recursion
void subset_sum(int arr[],int i,int j,int sum)
{
    if(i>j){
        printf("%d",sum);
        return; 
    }

    subset_sum(arr,i+1,j,sum+arr[i]);
    subset_sum(arr,i+1,j,sum);
}

//driver code
int main() 
{
    int arr[]={1,2,3};
    int n=sizeof(arr)/sizeof(arr[0]);

    //Function call to print subset sum
    subset_sum(arr,0,n-1,0);
    return 0;
}

Embed on website

To embed this program on your website, copy the following code and paste it into your website's HTML: