Create a program that countsand displaysthe odd and even numbers among the ten(10)input values.Array Requirements:Use 3separate arraysforteninput values, evenand odd num
#include <iostream>
#include <vector>
using namespace std;
void main()
{
const int N = 10;
int arr[N];
vector<int>even;
vector<int>odd;
cout << "Please, enter 10 integer values: ";
for (int i = 0; i < N; i++)
{
cin >> arr[i];
}
for (int i = 0; i < N; i++)
{
if (arr[i] % 2 == 0)
even.push_back(arr[i]);
else
odd.push_back(arr[i]);
}
cout << "\nEven numbers: ";
for (int i = 0; i < even.size(); i++)
{
cout << even[i]<<" ";
}
cout<< "\nOdd numbers: ";
for (int i = 0; i < odd.size(); i++)
{
cout << odd[i]<<" ";
}
}
Comments
Leave a comment