#include
int Average(int i);
int main()
{
int num;
do
{
printf("Enter numbers.\n");
scanf("%d",&num);
if(num != -1)
printf("The average is %d", Average(num));
printf("\n");
}while(num>-1);
return 0;
}
int Average(int i)
{
static int sum = 0, count = 0;
sum = sum + i;
count++;
return sum / count;
}
No comments:
Post a Comment