Product of values of all possible non | C ++ implementation of the approach ; Function to find product of all elements in all subsets ; Driver Code
#include <bits/stdc++.h> NEW_LINE using namespace std ; int product ( int a [ ] , int n ) { int ans = 1 ; int val = pow ( 2 , n - 1 ) ; for ( int i = 0 ; i < n ; i ++ ) { ans *= pow ( a [ i ] , val ) ; } return ans ; } int main ( ) { int n = 2 ; int a [ ] = { 3 , 7 } ; cout << product ( a , n ) ; return 0 ; }