//*****************************************************************
// R. A. Hillyard
// histogram3.cpp
// Oct 2000
//
//  See histogram1.cpp for comments
//  
//  This version shows initial value problem
//*****************************************************************

#include <iostream>

using namespace std;

void initialize(int anyArray[], int size);

const int NUM_RANGES = 11;

int main()
  {
  int score;              //variable for user input
  int range[NUM_RANGES];  //range[k] holds the number of scores seen
                          //so far between 10*k and 10*k + 9
  
  //initialize the counters
  //(range, NUM_RANGES);

  cout << "Enter scores --- (-1 to quit)" << endl;
  do
    {
    cout << "> ";
    cin >> score;
    if (score == -1)
      break;
    range[score / 10]++;
    } while (true);

  cout << endl << "Histogram of scores:" << endl;
  for (int k = 0; k < NUM_RANGES-1; k++)
    cout << 10*k << " to " << 10*k + 9 << " : " << range[k] << endl;

  cout << "100      : " << range[10] << endl;
  return 0;
  }
//*****************************************************************
// initialize - expects a referance to an array of ints and
// the size of the array - sets all elements of the array to 0
//*****************************************************************
void initialize(int a[], int size)
  {
  for(int k = 0; k <size; k++)
    a[k] =  0;  // initialize the counters
  }//end initialize

//*********************Program Output******************************
Enter scores --- (-1 to quit)
> 87
> 55
> 44
> 33
> 98
> 12
> 7
> 34
> 33
> 66
> 77
> 88
> 99
> 100
> 100
> 0
> 34
> 94
> 87
> -1

Histogram of scores:
0 to 9 : 1073871598
10 to 19 : -1073742711
20 to 29 : 1073782384
30 to 39 : 1074039583
40 to 49 : 134519885
50 to 59 : -1073742635
60 to 69 : 2
70 to 79 : -1073742711
80 to 89 : 134514894
90 to 99 : 134519791
100      : 134519886