Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a program in which you create an array of type double with 200 elements. P

ID: 3761024 • Letter: W

Question

Write a program in which you create an array of type double with 200 elements. Populate the array with random integers between 1 and 1000 (even though your array is of type double, you can still populate it with integers). Using the statistics library, calculate and output the following values: maximum, minimum, mean, standard deviation, and variance. Next, sort the array and output the median value. Ask the user to enter a search value and return the result of both the linear search and the binary search, where the result is the index of the first instance of the value that is found.  Add the sort and search functions to your statistics library.

Explanation / Answer

#include<iostream.h>
#include<conio.h>
#include<stdlib.h>
#include<math.h>

void main()
{
   double a[200];
   int i,j,s=0,nn;
   float av;
   int min=1, max=1000,sd1=0,sd;

   clrscr();
   for(i=0;i<200;i++)
   {
       a[i]=rand()+(max-min+1)+min;
       s=s+a[i];

   }
   av=s/28;

   cout<<"Average is :"<<av;

   int mx=a[0];
   for(i=0;i<200;i++)
   {
       if(a[i]>mx)
       mx=a[i];
   }


   int mi=a[0];
   for(i=0;i<200;i++)
   {
  
       if(a[i]<mi)
           mi=a[i];
       sd1 = sd1+sqrt((pow(a[i]-av,2)));

       }
   }
   sd=sd1/28;
   cout<<"Minimum = "<<mi<<endl;
   cout<<"Maximum = "<<mx<<endl;
   cout<<"Mean = "<<av<<endl;
   cout<<"Standard Deviation ="<<sd;

   cout<<"Enter the value to search";
   cin>>nn;

   for(i=0;i<200;i++)
   {
       if(a[i]==nn)
       {
           cout<<"Number found at

"<<i;
       }
   }

   getch();
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote