Count number of Odd and Even numbers in the given array in C++

This program helps you to find the number of even and odd numbers present in the given array

Source code :

#include<iostream>

using namespace std;

int main(){
    
int odd=0,even=0;

int numbers[10] = {7,10,4,13,8,5,10,25,88,14}; //Change the numbers here

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

    cout<<"\nThere are " <<even<<" even numbers in the give array";
    cout<<"\nThere are " <<odd<< " odd numbers in the give array";
    
return 0;
}

Output :

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

Output :


                

Comments :