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

1.) Flowchart of your program. (4 points) Printout of your C++ program with a he

ID: 3685487 • Letter: 1

Question

1.)

Flowchart of your program. (4 points)

Printout of your C++ program with a heading comment (Do not forget to

add comments within your program). (4 points)

Copy of a screenshot after your program is executed. (2 points)

You must use an array in order to receive any credit.

Formula for Corrected Sample Standard Deviation

/*

ELEN 1301-48F Programming Assignment #10.

Name : Your name.

Student ID : Your student ID #.

Due date :

Purpose of the program:

Create a program that generates 20 random numbers and find the average

and the corrected sample standard deviation.

Section 1 Set a random number seed with 2 followed by the last 3

digits of your student ID.

Section 2 Generate 20 random numbers, each ranging from 0 to 9, and

store them in an array while showing each value.

Section 3 Calculate the average and the corrected sample standard

deviation.

*/

Explanation / Answer

1.)

//Program to calculate sd

#include <iostream>
#include <cmath>
using namespace std;

double deviation(const double , int);
double mean (const double , int);

int main ()
{

   int size=10;
   double x[]={1,2,3,4,5,6,7,8,9,10};
   double m,d;
  
   m=mean(x, size);
   d=deviation (x, size);
   cout<<"The mean is:"<<m;
   cout<<"The standard deviation is:"<<d;
   return 0;

}

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

double deviation (const double x[], int size)
{
   double deviation;
   double sum2;
   double mean;
   //size=10;
   for ( int i = 0; i <=size; i++ )
   {
       sum2 += pow((x[i]-mean),2);
   }
   deviation= sqrt(sum2/(size-1));
   return deviation;
}

2.)

#include <iostream>
#include <cmath>
using namespace std;

double deviation(const double , int);
double mean (const double , int);

int main ()
{

   int size=20;
   double x[20];
   double m,d;

   for(i=0;i<19;i++)
   {
       x[i]=rand()%9;
   }
  
   m=mean(x, size);
   d=deviation (x, size);
   cout<<"The mean is:"<<m;
   cout<<"The standard deviation is:"<<d;
   return 0;

}

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

double deviation (const double x[], int size)
{
   double deviation;
   double sum2;
   double mean;
   //size=10;
   for ( int i = 0; i <=size; i++ )
   {
       sum2 += pow((x[i]-mean),2);
   }
   deviation= sqrt(sum2/(size-1));
   return deviation;
}