C program for function of average
int average(int);
void main()
{
int max=0,c=0;
clrscr();
printf("ENTER THE LIMIT OF INPUT FOR AVERAGE: ");
scanf("%d",&max);
c=average(max);
printf("THE AVERAGE OF %d DIGIT IS %d",max,c);
getch();
}
int average(int i)
{
int j=0,n=0,sum=0;
for(j=1;j<=i;j++)
{
printf("ENTER THE DIGIT: ");
scanf("%d",&n);
sum=sum+n;
}
sum=sum/i;
return(sum);
}
OUTPUT :
ENTER THE LIMIT OF INPUT FOR AVG : 5
ENTER THE DIGIT: 5
ENTER THE DIGIT : 10
ENTER THE DIGIT : 15
ENTER THE DIGIT : 20
ENTER THE DIGIT : 10
THE AVERAGE OF 5 DIGIT IS 12