Count number of Odd and Even numbers in the given array in Perl

Perl Program to count number of Odd and Even numbers in the given array

Source code :



$odd=0;
$even=0,i;

@numbers = (7,10,4,13,8,5,10,25,88,14);
$count = @numbers;

for($i=0; $i < $count ; $i=$i+1){
    
	if( $numbers[$i] %2 == 0){
	    $even = $even+1;
	}else{
	    $odd = $odd+1;
	}
	
}

print("There are $even even numbers in the give array");
print("\nThere are $odd odd numbers in the give array");
    

Output :

There are 6 even numbers in the give array
There are 4 odd numbers in the give array

Output :


                

Comments :