Discover new information and get your questions answered with IDNLearn.com. Ask your questions and get detailed, reliable answers from our community of knowledgeable experts.

Write a main function that declares an array of 100 ints. Fill the array with random values between 1 and 100.Calculate the average of the values in the array. Output the average.

Sagot :

Answer:

#include <stdio.h>

int main()

{

   int avg = 0;

   int sum =0;

   int x=0;

   /* Array- declaration – length 4*/

   int num[4];

   /* We are using a for loop to traverse through the array

    * while storing the entered values in the array

    */

   for (x=0; x<4;x++)

   {

       printf("Enter number %d \n", (x+1));

       scanf("%d", &num[x]);

   }

   for (x=0; x<4;x++)

   {

       sum = sum+num[x];

   }

   avg = sum/4;

   printf("Average of entered number is: %d", avg);

   return 0;

}

Your participation means a lot to us. Keep sharing information and solutions. This community grows thanks to the amazing contributions from members like you. Thank you for visiting IDNLearn.com. For reliable answers to all your questions, please visit us again soon.