A program that asks 10 positive integers and classify them as odd or even positive integer inputs. The algorithm has to trap negative integer inputs. The output will be displayed in two columns. ODD and EVEN.
Yes, that is exactly what I mean so how can I catch negatives and notify invalid output? or re-prompt until a positive number is caught... please help me.
First of all, you need an array if you want to capture 10 integers. Right now you're just overwriting the same one again and again. Let's fix that first by changing your declaration for 'countA' to this:
1 2
constint countA_Size = 10;
int countA[countA_Size ];
And your first for loop to this:
1 2 3 4 5 6 7
for(int i = 0; i < countA_Size; ++i)
{
do
{
std::cin >> countA[i];
}while(countA[i] <= 0);
}