I am trying to keep the value entered intot the array each time a number is entered and then average that number dividing by the count of [i] for the number of times a value was entered into the array. So far I can take the input but it is only held through the first iteration. It appears to be overwritten each time. Please send help to let me know what I am doing wrong.
#include <stdio.h>
int main()
{
int number[10]; /* array of 10 numbers */
int count = 10; /* count through the amount of times entered */
long sum = 0L; /* The total amount of the numbers entered */
float average = 00.0f; /* average of the total / count */
int i = 0; /* count through the array */
char more = 'y'; /* variable to continue with the loop y||Y */
/* do loop to go through the user input */
do
{
for(i =0; i <= count; i++)
{
printf("\n Enter the number you wish to average:\n"); /* enter the numbers display to the user */
scanf("%d", &number[i]); /* read input */
average = (float)(10 * number[i] / count);
printf(" The value you entered was %d\n", number[i]);
printf(" The average of these numbers is %.2f\n", average);
printf("Would you like to try another value? (N/Y)?: \n"); /* ask for more input values */
scanf(" %c", &more); /* look for value to be yes or no */
if (more == 'N' || more == 'n')
{ break;}
}
}while(more == 'Y' || more == 'y');
}