Name this program stats c This program below performs some

Name this program stats. c - This program below performs some basic statistics on an array of 5 integers. It must use the five functions indicated. You need to complete this program (write the five functions)_ #include #include void getData(int, int[]); double getMean(int, int[]); double getVariance(int, int[], double); double getStdDev(double); void printResults(double, double, double); int main() {int size = 5, array[5]; double mean, variance, stddev; getData(size, array); mean = getMean(size, array); variance = getVariance(size, array, mean); stddev = getStdDev(variance); printResults(mean, variance, stddev); return 0;

Solution

   #include <stdio.h>
   #include <math.h>
   void getData(int size, int data[]);
   double getMean(int size, int array[]);
   double getVariance(int size, int array[], double mean);
   double getStdDev(double variance);
   void printResults(double mean,double variance,double stdDev);
   int main() {
       int size = 5, array[5];
       double mean, variance, stddev;
       getData(size, array);
       mean = getMean(size, array);
       variance = getVariance(size, array, mean);
       stddev = getStdDev(variance);
       printResults(mean, variance, stddev);
       return 0;
   }
   void getData(int size, int data[])
   {
   int x;
       for (x=0; x<size;x++)
   {
   printf(\"Enter the integer number %d\ \", x);
   scanf(\"%d\", &data[x]);
   }
   printf(\"All the integers have been entered\ \");
   }

   double getMean(int size, int array[])
   {
   int x;
       int mean, sum = 0;
       for(x=0; x<size; x++)
       {
           sum = sum+array[x];
       }
       mean = sum/size;
       return mean;
   }

   double getVariance(int size, int array[], double mean)
   {
   int x;
   double variance, sum =0;
       for(x=0; x<size; x++)
       {
           double diff = array[x] - mean;
           sum = sum+pow(diff, 2);
       }
       variance = sum/size;
       return variance;
   }

   double getStdDev(double variance)
   {
       double stdDev = sqrt(variance);
       return stdDev;
   }

   void printResults(double mean, double variance, double stdDev)
   {
       printf(\"The mean of the numbers is %d\ \", mean);
       printf(\"The variance of the numbers is %d\ \", variance);
       printf(\"The standard deviation of the numbers is %d\ \", stdDev);
   }

 Name this program stats. c - This program below performs some basic statistics on an array of 5 integers. It must use the five functions indicated. You need to
 Name this program stats. c - This program below performs some basic statistics on an array of 5 integers. It must use the five functions indicated. You need to

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site