Add minimum number to an array so that the sum becomes even | C # program to add minimum number so that the sum of array becomes even ; Function to find out minimum number ; Count odd number of terms in array ; Driver Code
using System ; class GFG { static int minNum ( int [ ] arr , int n ) { int odd = 0 ; for ( int i = 0 ; i < n ; i ++ ) if ( arr [ i ] % 2 != 0 ) odd += 1 ; return ( ( odd % 2 ) != 0 ) ? 1 : 2 ; } public static void Main ( ) { int [ ] arr = { 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 } ; int n = arr . Length ; Console . Write ( minNum ( arr , n ) ) ; } }