Create an array of size ten; get input from user, show only odd values in one go and then even values in one go.
#include <iostream>
using namespace std;
int main( )
{
int arr[10];
cout << "Enter numbers of array\n";
for (int i = 0; i < 10; ++i)
{
cin >> arr[i];
}
for (int i = 0; i < 10; ++i)
{
if (arr[i] % 2 == 0)
{
cout << arr[i] << " ";
}
}
cout << "\n";
for (int i = 0; i < 10; ++i)
{
if (arr[i] % 2 != 0)
{
cout << arr[i] << " ";
}
}
return 0;
}
Comments
Leave a comment