Function to find the maximum product
static void maxProductSum ( string str , int m ) { int n = str . Length ; int maxProd = int . MinValue , maxSum = int . MinValue ; for ( int i = 0 ; i <= n - m ; i ++ ) { int product = 1 , sum = 0 ; for ( int j = i ; j < m + i ; j ++ ) { product = product * ( str [ j ] - '0' ) ; sum = sum + ( str [ j ] - '0' ) ; } maxProd = Math . Max ( maxProd , product ) ; maxSum = Math . Max ( maxSum , sum ) ; } Console . WriteLine ( " Maximum ▁ Product ▁ = ▁ " + maxProd ) ; Console . Write ( " STRNEWLINE Maximum ▁ Sum ▁ = ▁ " + maxSum ) ; }