Answer to Question #3322 in C++ for mukunda

Question #3322
Take N numbers in an array; print all even numbers and odd numbers separately.
1
Expert's answer
2011-07-11T10:03:18-0400
#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;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS