C++ program to count numbers of even and odd elements in an array
Program to count the number of even and odd elements in an array
Here we will going to learn about the process of counting the number of even and odd elements in an array which is discussed here. Given an array of integers, count the total number of odd elements and even elements in the array and display them as output.
Input – 1,2,3,4
odd elements- 2
- Input the number of elements of the array.
- Input the array elements.
- Initialize count_odd = count_even = 0.
- Traverse the array and increment count_odd if the array element is odd, else increment count_even.
- Print count_odd and count_even.