Find the count of even odd pairs in a given Array | Java program to count the pairs in array of the form ( even , odd ) ; Function to count the pairs in array of the form ( even , odd ) ; Variable to store count of such pairs ; Iterate through all pairs ; Increment count if condition is satisfied ; Driver code
import java . util . * ; class GFG { static int findCount ( int arr [ ] , int n ) { int res = 0 ; for ( int i = 0 ; i < n - 1 ; i ++ ) for ( int j = i + 1 ; j < n ; j ++ ) if ( ( arr [ i ] % 2 == 0 ) && ( arr [ j ] % 2 == 1 ) ) { res ++ ; } return res ; } public static void main ( String [ ] args ) { int a [ ] = { 5 , 4 , 1 , 2 , 3 } ; int n = a . length ; System . out . print ( findCount ( a , n ) ) ; } }