Product of all Subarrays of an Array | Function to find product of all subarrays ; Variable to store the product ; Compute the product while traversing for subarrays ; Printing product of all subarray ; Driver code ; Function call
function product_subarrays ( arr , n ) { var res = 1 ; for ( var i = 0 ; i < n ; i ++ ) { var product = 1 ; for ( var j = i ; j < n ; j ++ ) { product = product * arr [ j ] ; res *= product ; } } document . write ( res ) ; } var arr = [ 10 , 3 , 7 ] ; var n = arr . length ; product_subarrays ( arr , n ) ;