Check whether the given integers a , b , c and d are in proportion | C # implementation of the approach ; Function that returns true if the given four integers are in proportion ; Array will consist of only four integers ; Sort the array ; Find the product of extremes and means ; If the products are equal ; Driver code
using System ; class GFG { static bool inProportion ( int [ ] arr ) { int n = 4 ; Array . Sort ( arr ) ; long extremes = ( long ) arr [ 0 ] * ( long ) arr [ 3 ] ; long means = ( long ) arr [ 1 ] * ( long ) arr [ 2 ] ; if ( extremes == means ) return true ; return false ; } public static void Main ( String [ ] args ) { int [ ] arr = { 1 , 2 , 4 , 2 } ; if ( inProportion ( arr ) ) Console . WriteLine ( " Yes " ) ; else Console . WriteLine ( " No " ) ; } }