Sum of all ordered pair | C # program to implement the above approach ; Function to calculate the sum of all pair - products ; Stores sum of array ; Update sum of the array ; Driver code
using System ; class GFG { static int sumOfProd ( int [ ] arr , int N ) { int sum = 0 ; for ( int i = 0 ; i < N ; i ++ ) { sum += arr [ i ] ; } return sum * sum ; } static void Main ( ) { int [ ] arr = { 2 , 3 , 1 , 5 , 4 } ; int N = arr . Length ; Console . WriteLine ( sumOfProd ( arr , N ) ) ; } }