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<
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;
}
![](/static/compass_v2/shared-icons/check-mark.png)
Step by step
Solved in 2 steps
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)