/**********************************
  File:  hw2p4.c

for integer n>=1,  print table with
integer i, ranging from 1 to n, in the 
left column and the average of the 
first i numbers in the  right column

***********************************/

#include <stdio.h>
#include "simpio.h"

void main()
{
  int n=0, i=0;
  double sum=0.0;

    printf("Enter an integer n: ");
    n=GetInteger();

    while (n<1) {
      printf("n must be positive, try again: ");
      n=GetInteger();
    }
    
  printf("i\t\tavg\n-----------------------------\n");
  for (i=1; i<=n; i++)
    printf("%d\t\t%.2f\n", i, (sum += i)/i);
}

