Code:
#include <iostream>
using namespace std;
int main() // main returns int, not void
{
int number; // number is more descriptive than just "input"
// initialize variables in 1 line, saves space looks cleaner
int positive = 0, negative = 0, odd = 0, even = 0;
// we don't want to count the Ctrl-Z character as a number, so
// I structured the input loop a bit differently (and correctly)
// user inputs a number
cout <<"enter a number (ctrl-z to quit): ";
cin >> number;
// test if it's ctrl-Z
// if it is, skip this loop
while (!cin.eof())
{
if ((number % 2) == 0)
even++; // the right way to increment this number
else // if not even, it was odd - no need to do another test
odd++;
if (number > 0) // same idea as above
positive++;
else
negative++;
// user enters next number
cout <<"enter a number (ctrl-z to quit): ";
cin >> number;
// which gets tested again at the top, thereby avoiding
// counting ctrl-z as a valid number.
}
cout <<"positive = "<<positive<<endl;
cout <<"negative = "<<negative<<endl;
cout <<"even = "<<even<<endl;
cout <<"odd = "<<odd<<endl;
}