#include <stdio.h>
void main()
{
int numbers[10]; /* Array storing 10 values */
int count = 10; /* Number of values to be read */
long sum = 0L; /* Sum of the numbers */
float average = 0.0f; /* Average of the numbers */
int i = 0; /* Loop counter */
printf("\nEnter the 10 numbers:\n");
/* Read the ten numbers to be averaged */
for(i = 0; i < count; i ++)
{
printf("%2d : ",i+1);
scanf("%d", &numbers[i]); /* Read a number */
sum += numbers[i]; /* Add it to sum */
}
average = (float)sum/count; /* Calculate the average */
printf("Average of the ten numbers entered is: %f\n", average);
}
|