Maximum possible elements which are divisible by 2 | C # program to find maximum possible elements which divisible by 2 ; Function to find maximum possible elements which divisible by 2 ; To store count of even numbers ; All even numbers and half of odd numbers ; Driver code ; Function call
using System ; class GFG { static int Divisible ( int [ ] arr , int n ) { int count_even = 0 ; for ( int i = 0 ; i < n ; i ++ ) if ( arr [ i ] % 2 == 0 ) count_even ++ ; return count_even + ( n - count_even ) / 2 ; } static public void Main ( ) { int [ ] arr = { 1 , 2 , 3 , 4 , 5 } ; int n = arr . Length ; Console . Write ( Divisible ( arr , n ) ) ; } }