Answer:
#include <iostream>
using namespace std;
int main() {
int numVals;
bool allPositive = true;
int inputVal;
cout << "Enter the number of integers: ";
cin >> numVals;
for (int i = 0; i < numVals; i++) {
cin >> inputVal;
if (inputVal <= 0) {
allPositive = false;
}
}
if (allPositive) {
cout << "All match" << endl;
}
else {
cout << "Not all match" << endl;
}
return 0;
}
Step-by-step explanation:
The program first declares a variable allPositive of type boolean and initializes it to true. Then it reads an integer numVals from input representing the number of integers to be read next. Using a loop, it reads the remaining integers one by one and checks if each integer is positive (greater than 0). If any integer is not positive, allPositive is set to false. Finally, the program outputs "All match" if allPositive is true and "Not all match" if allPositive is false.