Source code:
/*Consider the function find average findavg() , which takes an array as an argument along with another argument and based on the passed arguments and it returns the average of the numbers passed through the array. Consider an array of size 10. It reads 5 marks and find the average. */
#include<stdio.h>
int findavg(int marks[]);
int findavg(int marks[])
{
int i, sum = 0;
int avg;
for (i = 0; i <= 4; i++) {
sum += marks[i];
}
avg = (sum / 5);
return avg;
}
int main()
{
int avg; int marks[10];int i;int n=5;
/* Read Marks*/
printf("Enter marks of 5 subject: ");
for (i=0; i<n; i++)
scanf("%d",&marks[i]);
avg = findavg(marks);
printf("Average=%d", avg);
return 0;
}
Output: