Handout - while loop

//
// This program inputs a series of integers one at a time
// and determines whether they are even or odd.  It uses
// a while loop and demonstrates the use of the % operator
//

#include < iostream>

using namespace std;

int main()
{
  int count, times;        // used to control the looping
  int number;              // number to be tested for "oddness"

  cout << "Enter the number of integers to test:  ";
  cin >> times;

  count = 0;               // init the l.c.v.
  while (count < times)
  {
    cout << "Enter an integer:  ";
    cin >> number;

    if (number % 2)
      cout << number << " is an odd number" << endl;
    else
      cout << number << " is an even number" << endl;

    count = count + 1;     // update the l.c.v.
  }
  return 0;
}