Computer Science, asked by tanvirana2829, 8 months ago

Compute the average weight for a population of elephant seals read into an array using c language.elephant seal weights (elephant_seal_data), read them into an array and compute the average weight for the set of the elephant seals.

Answers

Answered by poojan
13

Program:

#include <stdio.h>

int main()

{

   int n, i;

   float weight[1000], sum=0.0, avg;

   printf("Enter the numbers of weights you are going to enter and make sure that the number is in between 0 and 1000: ");

   scanf("%d", &n);

   printf("Enter the weights into the array");

   for (i = 0; i < n; ++i)

   {

       printf("Enter weight %d: ", i+1);

       scanf("%f", &weight[i]);

       sum = sum + weight[i];

   }

   avg = sum / n;

   printf("Average weight for the set of the elephant seals. = %.4f units", avg);

   return 0;

}

Input:

Enter the numbers of weights you are going to enter and make sure that the number is in between 0 and 1000: 5

Enter the weights into the array

Enter weight 1: 72.98

Enter weight 2: 89.64

Enter weight 3: 64

Enter weight 4: 59.08

Enter weight 5: 112.56

Output:

Average weight for the set of the elephant seals. = 79.6520 units

Learn more:

1. Write a program that inputs numbers and keeps a running sum. When the sum is greater than 100, output the sum as well as the count of how many...

https://brainly.in/question/8171976

2. write a C program to find the smallest number among three numbers using nested if else statement.

https://brainly.in/question/8459549

Similar questions