Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and beauty - Write a function in c++ to find the number of all odd elements and the number of all even elements in the one-dimensional integer array a[n].

#include

using namespace std;

Write a function in c++ to find the number of all odd elements and the number of all even elements in the one-dimensional integer array a[n].

#include

using namespace std;

Write a function in c++ to find the number of all odd elements and the number of all even elements in the one-dimensional integer array a[n].

#include

using namespace std;

void fun2(int a[],int n,int& c1,int& c2){

for(int i=0;i

if(a[i]%2==0){

c2++;

}

else{

c1++;

}

}

}

int main(){

int n=100,c1=0,c2=0;

cout<<"Input the number of array elements:";< /p>

cin>>n;

int a[n];

cout<<"Input array element:"<

for(int i=0;i

cin>>a[i];

}

fun2(a,n ,c1,c2);

cout<<"The number of odd elements is:"<

return 0;

}