Hi all,
I am doing an exercise in Netbeans from the C++ Primer book. The questions is: "Write a program to ask the user to enter a series of numbers. Print a message saying how many of the numbers are negative numbers."
I wrote the below code:
However, when I run the program in Netbeans, I input a series of numbers and hit Enter. Nothing happens as if the program is waiting for more. Is there something Netbeans-specific that's causing the issue? The answer given on the following site (for question 1.17) is similar to mine: 1.4.3 - CppPrimerCode:#include <cstdlib> #include <iostream> using namespace std; int main () { std::cout << "Enter a series of numbers separated by spaces:" << std::endl; int a, negativeCounter = 0; while (std::cin >> a) { if (a < 0) { ++negativeCounter; } } std::cout << "You gave me " << negativeCounter << " negative numbers." << std::endl; return 0;