# Answer to Question #3322 in C++ for mukunda

Question #3322

Take N numbers in an array; print all even numbers and odd numbers separately.

Expert's answer

#include <iostream>

using namespace std;

int main()

{

const int N = 5;

int arr[N] = { 10, 46, 37, 8, 19 };

cout << "Even numbers: ";

for (int i = 0; i < N; ++i)

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

& cout << arr[i] << " ";

cout << endl;

cout << "Odd numbers: ";

for (int i = 0; i < N; ++i)

& if (arr[i] % 2 == 1)

& cout << arr[i] << " ";

cout << endl;

return 0;

}

using namespace std;

int main()

{

const int N = 5;

int arr[N] = { 10, 46, 37, 8, 19 };

cout << "Even numbers: ";

for (int i = 0; i < N; ++i)

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

& cout << arr[i] << " ";

cout << endl;

cout << "Odd numbers: ";

for (int i = 0; i < N; ++i)

& if (arr[i] % 2 == 1)

& cout << arr[i] << " ";

cout << endl;

return 0;

}

## Comments

## Leave a comment