AVERAGE CALCULATOR FUNCTION
Code :
#include<stdio.h>
int average(int n1, int n2, int n3);
int main()
{
int num1,num2,num3, avg;
printf("\t AVERAGE CALCULATOR\n");
printf("--------------------------------------\n");
printf("Enter 3 numbers to calculate average:\n");
scanf("%d", &num1);
scanf("%d", &num2);
scanf("%d", &num3);
avg = average(num1, num2, num3);
printf("\nAverage = %d\n\n", avg);
printf("**************************************\n");
return 0;
}
// Function to calculate average.
int average(int n1, int n2, int n3){
int sum, avg;
sum = n1 + n2 + n3;
avg = sum / 3;
return avg;
}