Frequencies of even and odd numbers in a matrix | Java Script Program to Find the frequency of even and odd numbers in a matrix ; function for calculating frequency ; even and odd ; print Frequency of numbers ; Driver code
let MAX = 100 ; function freq ( ar , m , n ) { let even = 0 , odd = 0 ; for ( let i = 0 ; i < m ; ++ i ) { for ( let j = 0 ; j < n ; ++ j ) { if ( ( ar [ i ] [ j ] % 2 ) == 0 ) ++ even ; else ++ odd ; } } document . write ( " " + odd + " " ) ; document . write ( " " + even + " " ) ; } let m = 3 , n = 3 ; let array = [ [ 1 , 2 , 3 ] , [ 4 , 5 , 6 ] , [ 7 , 8 , 9 ] ] ; freq ( array , m , n ) ;