write a program to accept 20 integer numbers in a Single Dimensional Array. Find and display the number of even numbers
Answers
Answer:
Hi...
It's a python code..
Explanation:
Hope it helps you..
Please mark brainliest..
Answer:
// CPP program to count number of even
// and odd elements in an array
#include<iostream>
using namespace std;
void CountingEvenOdd(int arr[], int arr_size)
{
int even_count = 0;
int odd_count = 0;
// loop to read all the values in the array
for(int i = 0 ; i < arr_size ; i++)
{
// checking if a number is completely
// divisible by 2
if (arr[i] & 1 == 1)
odd_count ++ ;
else
even_count ++ ;
}
cout << "Number of even elements = " << even_count
<< "\nNumber of odd elements = " << odd_count ;
}
// Driver Code
int main()
{
int arr[] = {2, 3, 4, 5, 6};
int n = sizeof(arr) / sizeof(arr[0]);
CouningEvenOdd(arr, n);
}