app/site-content/proposals/2009/07/29/c.c
author Madhusudan.C.S <madhusudancs@gmail.com>
Sat, 08 Aug 2009 23:54:36 +0530
changeset 18 05b9e60e6a10
parent 0 c94bd9ae70d2
permissions -rwxr-xr-x
Changed CSS and removed Withdraw proposal.

#include <stdio.h>

main()
{

  int n, count = 1;
  float x, sum = 0,average;
  do {
    printf("how many numbers? ");
    scanf("%d", &n);
    sum = 0;
    count = 1;
    while (count <= n)   {
      printf("x = ");
      printf("\n(to end program, enter 0 for x): ");
      scanf("%f", &x);
      if (x == 0) 
        break;
      sum += x;
      ++count;
    }
    average = sum/n;
    printf("\nthe average is %f\n", average);
  } while (x != 0); 
}