average of 5 numbers in c using function
/* here i needed to do of 5 numbers so the array is set to store only 5 numbers
you can set it to user desire using a varaible*/
#include <stdio.h>
#include <conio.h>
float avg();
void main ()
{
printf("\nThe average of 5 numbers is %.2f\n",avg());
}
float avg()
{
int i,num[5],sum=0;
float average=0;
for(i=0; i < 5; i++)
{
printf("Enter number %d: ",i+1);
scanf("%d",&num[i]);
sum = sum + num[i];
}
average = sum / 5.0;
return average;
}