Name your program file statscpp Do not use any global variab

Name your program file stats.cpp Do not use any global variables Use only iostream and iomanip functions for I/O and formatting (no stdio) Read a list of integers from the console one at a time a. Place each integer into an array b. A low for a maximum (not total) of 100 scores (see Analyze and Loops - the examples at the bottom of the page) c. None of the entered scores will be 90 Bin H: score greaterthanorequalto 70 but

Solution

Answer:

#include <iostream>
#include <iomanip>
#include <cmath>

using namespace std;

//Function prototypes
int* histogram(int arr[], int length);
double deviation(int arr[], int length);
double mean(int arr[], int length);

int main() {
   int arr[100];
   int count=0;
   int temp;
   double sd;
   cout<<\"Enter the scores, enter -1 to stop\"<<endl;
   while(count<100)
   {
        cout<<\"Enter value \"<<count+1<<\": \";
        cin>>temp;
        if(temp == -1)
        {
            break;
        }
        else if(temp < 0)
        {
            cout<<\"You entered an invalid score.\";
            continue;
        }
        else
        {
            arr[count] = temp;
            count++;
        }
   }
   sd = deviation(arr, count);
   cout<<\"The standard deviation is:\"<<sd;
}

//Since the question doesn\'t provide the format of the histogram function\'s output I am providing
//the deviation an mean functions here
double deviation(int arr[], int length)
{
    double avg=0, sd=0;
    avg = mean(arr, length);
    for(int i=0; i<length; i++)
    {
        sd += pow((arr[i] - avg), 2);
    }
  
    sd = sqrt(sd/length);
    return sd;
}

double mean(int arr[], int length)
{
    double sum=0, mean=0;
    for(int i=0; i<length; i++)
    {
        sum += arr[i];
    }
    mean = sum/length;
    return mean;
}

--------------------------------------------------------------------------------------------------------------------------

OUTPUT:

Enter the scores, enter -1 to stop.

Enter value 1:12

Enter value 2:21

Enter value 3:23

Enter value 4:32

Enter value 5:-1

The standard deviation is:7.10634

 Name your program file stats.cpp Do not use any global variables Use only iostream and iomanip functions for I/O and formatting (no stdio) Read a list of integ
 Name your program file stats.cpp Do not use any global variables Use only iostream and iomanip functions for I/O and formatting (no stdio) Read a list of integ

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site