Please find the required C++ script as the following:
//========================================================
#include <iostream>
#include <iomanip> // For controlling double precision
#include <math.h>
using namespace std;
#define size 10
double stdDev(double* arr,int arr_size)
{
int i;
double sum_n=0,sum_n2=0,std_val;
for(i=0;i<arr_size;i++)
{
sum_n=sum_n+arr[i]; // Calculating sum(xi)
sum_n2=sum_n2+(arr[i]*arr[i]); // Calculating sum(xi^2)
}
std_val = sqrt((sum_n2/arr_size)-pow(sum_n/arr_size,2));
return std_val;
}
int main() {
// Input array
double arr[size] = {11.2,2.4,3.13,16.4,5.8,9.22,4.9,10.5,6.5,2.99};
// Function call and output
cout <<setprecision(7)<<"Standard Deviation: "<<stdDev(arr,size)<<"\n";
return 1;
}
//===================================================
output:
Standard Deviation: 4.249367
Hope this helps!
************* PLEASE THUMBS UP!!!!!!!!!!! *************
In case of any clarification, please comment!
C++ Programme Write a function that receives, as arguments, a pointer to a double array, as...
(C++)Write a function that accepts an int array and the array’s size as arguments.The function should create a new array that is twice the size of the argument array.The function should copy the contents of the argument array to the new array, and initialize the unused elements of the second array with 0.The function should return a pointer to the new array.Demonstrate the function by using it in a main program that reads an integer N (that is not more...
c++ program8. Array/File Functions Write a function named arrayToFile. The function should accept three arguments: the name of a file, a pointer to an int array, and the size of the array. The function should open the specified file in binary mode, write the contents of the array to the file, and then close the file. Write another function named fileToArray. This function should accept three argu- ments: the name of a file, a pointer to an int array, and the size...
(C++ program )Write a function that accepts an int array and the array’s size as arguments. The function should create a new array that is one element larger than the argument array. The first element of the new array should be set to 0. Element 0 of the argument array should be copied to the element 1 of the new array. Element 1 of the argument array should be copied to element 2 of the new array, and so forth....
Help C++ Write a string class. To avoid conflicts with other similarly named classes, we will call our version MyString. This object is designed to make working with sequences of characters a little more convenient and less error-prone than handling raw c-strings, (although it will be implemented as a c-string behind the scenes). The MyString class will handle constructing strings, reading/printing, and accessing characters. In addition, the MyString object will have the ability to make a full deep-copy of itself...