Product of all Subarrays of an Array | Set 2 | C # program for the above approach ; Function to find the product of elements of all subarray ; Initialize the result ; Computing the product of subarray using formula ; Return the product of all elements of each subarray ; Driver code ; Given array arr [ ] ; Function Call
using System ; class GFG { static int SubArrayProdct ( int [ ] arr , int n ) { int result = 1 ; for ( int i = 0 ; i < n ; i ++ ) result *= ( int ) ( Math . Pow ( arr [ i ] , ( i + 1 ) * ( n - i ) ) ) ; return result ; } public static void Main ( ) { int [ ] arr = new int [ ] { 2 , 4 } ; int N = arr . Length ; Console . Write ( SubArrayProdct ( arr , N ) ) ; } }