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 |
0 | 1 |
#include <stdio.h> |
2 |
||
3 |
main() |
|
4 |
{ |
|
5 |
||
6 |
int n, count = 1; |
|
7 |
float x, sum = 0,average; |
|
8 |
do { |
|
9 |
printf("how many numbers? "); |
|
10 |
scanf("%d", &n); |
|
11 |
sum = 0; |
|
12 |
count = 1; |
|
13 |
while (count <= n) { |
|
14 |
printf("x = "); |
|
15 |
printf("\n(to end program, enter 0 for x): "); |
|
16 |
scanf("%f", &x); |
|
17 |
if (x == 0) |
|
18 |
break; |
|
19 |
sum += x; |
|
20 |
++count; |
|
21 |
} |
|
22 |
average = sum/n; |
|
23 |
printf("\nthe average is %f\n", average); |
|
24 |
} while (x != 0); |
|
25 |
} |
|
26 |
||
27 |