compute the average weight for a population of elephants seals read into an array
Answers
Explanation:
secure a teach for in the Trott t6t6r5e4d6f6d6r6d5s and ef78ffyyyyyyyttyft7t7f7ftftf6f8ty7t7tf7tttigr6tt ýtttr8t7t8t8
The required program is given below.
Explanation:
// C program to compute the average weight for a population of elephants seals read into an array.
#include <stdio.h>
void main()
{
int number_of_elephant_seals,elephant_seals[100],
average_weight,sum=0,i;
printf("Enter the number of elephants seals: ");
scanf("%d",&number_of_elephant_seals);
printf("\nEnter the weights of the %d
elephant seals:\n",number_of_elephant_seals);
for(i=1;i<=number_of_elephant_seals;i++)
{
scanf("%d",&elephant_seals[i]);
}
for(i=1;i<=number_of_elephant_seals;i++)
{
sum=sum+elephant_seals[i];
}
average_weight=sum/number_of_elephant_seals;
printf("\nThe average weight for a population of %d elephants
seals is equal to = %d kg",number_of_elephant_seals,average_weight);
}
Refer the attached image for the output.