/* whileLoopSentinel.c  P. Conrad 10/05/05 */
/* ask for grades until user types sentinel      */
/* compute min, max, count, average */


#include <stdio.h>

#define SENTINEL 999

int main(void)
{

  /* declare variables */

  int  testScore, maxScore, minScore;
  double average; 
  int testCount;
  int totalOfScores;

  /* initialize variables */

  testCount = 0; 
  totalOfScores = 0; 

  /* read first score */

  printf("Enter test scores (%d to end):",SENTINEL);
  scanf("%d", &testScore );

  while (testScore != SENTINEL)
    {
      /* process the score */
      
      testCount++;    /* same as testCount = testCount + 1; */
      totalOfScores = totalOfScores + testScore;

      /* read next score */

      printf("Enter test scores (%d to end):",SENTINEL);
      scanf("%d", &testScore );

    }

  /* do final calculations */

  if ( testCount != 0   )
    {
      average = (totalOfScores * 1.0) / testCount;
    }

  /* print results */


  printf("There were %d scores\n",testCount);

  
  return 0;

}



