I have tried to run this code but every time I try, the program finishes before the user can answer the question of displaying positive or negative integers. What am I doing wrong?
#include <iostream>
using namespace std;
int main() {
int number;
int positiveCount = 0;
int negativeCount = 0;
for (int i = 0; i < 10; i++) {
cin >> number;
if (number > 0) {
positiveCount++;
}
if (number < 0) {
negativeCount++;
}
}
char response;
cout << "Do you want the (p)ositive or (n)egative count? ";
cin >> response;
if (response == 'p') {
cout << "Positive count is " << positiveCount << "\n";
}
if (response == 'n') {
cout << "Negative count is " << negativeCount << "\n";
}
}