C++ Program to find even and odd elements in array


In this program, You will learn how to find even and odd elements in array in C++.


for (i = 0; i < 10; i++) {

if (arr[i] % 2 == 0) }


Example: How to find even and odd elements in array in C++

Run it Now
#include<iostream>
using namespace std;

int main() {

    int arr[10], i;

    cout << "Enter any 10 Numbers :";
    for (i = 0; i < 10; i++) {
        cin >> arr[i];
    }

    cout << "\nAll Even List is :";
    for (i = 0; i < 10; i++) {
        if (arr[i] % 2 == 0)
            cout << arr[i] << " ";
    }

    cout << "\nAll Odd List is :";
    for (i = 0; i < 10; i++) {
        if (arr[i] % 2 != 0)
            cout << arr[i] << " ";
    }

    return 0;
}

Output:

Enter any 10 Numbers :11 12 13 14 15 16 17 18 19 20
All Even List is :12 14 16 18 20
All Odd List is :11 13 15 17 19