make table for this codding     #include #include using namespace std;   //declaration of function void Smallest(int n, int arr[]); void Largest(int n, int arr[]); void findMean(int a[], int n); void standardDeviation(int a[], int n);   //main coding int main() { int a[100]; int n; cout<<"Input number of elements in the array "; cin>>n; int i; for (i=0;i> a[i]; } Smallest(n,a); Largest(n,a); findMean(a,n); standardDeviation(a,n);   return 0; }   //Function: Smallest //It will take a int n and int arr[] //and find the smallest value with the frequency void Smallest(int n, int arr[]) { int mn = arr[0], freq = 1; for (int i = 1; i < n; i++) { if (arr[i] < mn) { mn = arr[i]; freq = 1; } else if (arr[i] == mn) freq++; }   cout< mx) { mx = arr[i]; freq = 1; } else if (arr[i] == mx) freq++; }   cout<

Programming Logic & Design Comprehensive
9th Edition
ISBN:9781337669405
Author:FARRELL
Publisher:FARRELL
Chapter3: Understanding Structure
Section: Chapter Questions
Problem 7RQ
icon
Related questions
Question

make table for this codding

 

 

#include <cmath>

#include <iostream>

using namespace std;

 

//declaration of function

void Smallest(int n, int arr[]);

void Largest(int n, int arr[]);

void findMean(int a[], int n);

void standardDeviation(int a[], int n);

 

//main coding

int main()

{

int a[100];

int n;

cout<<"Input number of elements in the array ";

cin>>n;

int i;

for (i=0;i<n;i++)

{

    cout<<"Insert data : ";

    cin>> a[i];

}

Smallest(n,a);

Largest(n,a);

findMean(a,n);

standardDeviation(a,n);

 

return 0;

}

 

//Function: Smallest

//It will take a int n and int arr[]

//and find the smallest value with the frequency

void Smallest(int n, int arr[])

{

int mn = arr[0], freq = 1;

for (int i = 1; i < n; i++) {

if (arr[i] < mn) {

mn = arr[i];

freq = 1;

}

else if (arr[i] == mn)

freq++;

}

 

cout<<endl<<"Smallest value is "<<mn<<" and it's frequency is "<<freq<<endl;

}

 

//Function: Largest

//It will take a int n and int arr[]

//and find the largest value with the frequency

void Largest(int n, int arr[])

{

int mx = arr[0], freq = 1;

 

for (int i = 1; i < n; i++) {

if (arr[i] > mx) {

mx = arr[i];

freq = 1;

}

else if (arr[i] == mx)

freq++;

}

 

cout<<endl<<"Largest value is "<<mx<<" and it's frequency is "<<freq<<endl;

}

 

//Function: findMean

//It will take a int a[] and int n

//and calculate the mean

void findMean(int a[], int n)

{

double sum = 0;

for(int i = 0; i < n; i++){

sum = sum + a[i];//calculate sum of all numbers

}

double mean = sum/n;//find the mean

cout<<endl<<"The mean is = "<<mean<<endl; //display the mean

}

 

//Function: standardDeviation

//It will take a int a[] and int n

//and calculate the standard deviation

void standardDeviation(int a[], int n)

{

int sum = 0;

for (int i = 0; i < n; i++)

sum += a[i];

double mean = (double)sum /(double)n;

 

double sqDiff = 0;

for (int i = 0; i < n; i++)

sqDiff += (a[i] - mean) *

(a[i] - mean);

double sd = sqrt(sqDiff / n);

cout<<endl<<"Standard deviation is "<<sd<<endl;

}

Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Array
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage