Discover answers to your questions with Westonci.ca, the leading Q&A platform that connects you with knowledgeable experts. Explore in-depth answers to your questions from a knowledgeable community of experts across different fields. Our platform offers a seamless experience for finding reliable answers from a network of knowledgeable professionals.

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;

}