Given Arr[10] = {7, 9, 13, 15, 16, 10, 12, 5, 20, 27}
Write a program to count number of EVEN and ODD items. Do a screen output of your result.
for c++ please
Answer: main.cpp
#include <iostream>
using namespace std;
int main()
{
int Arr[]={7,9,13,15,16,10,12,5,20,27};
int evenCount=0, oddCount=0;
for(int i=0;i<10;i++){
if(Arr[i]%2==0)
evenCount++;
else
oddCount++;
}
cout<<"Number of even items :"<<evenCount;
cout<<"\nNumber of odd items :"<<oddCount;
return 0;
}
Output:
Get Answers For Free
Most questions answered within 1 hours.