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++ 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....
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...
1. Write code for a function that receives two parameters (a,and b) by value and two more parameters (c and d) by reference. All parameters are double. The function works by assigning c to (a/b) and assigning d to (a*b). The function has no return value. From main, use scanf to get two numbers, then call the function, and then display both outcome values to the output in a printf statement. 2. After part 1 is completed, write code to...
programing C,already write part of code (a) Write a function print.array that receives an array of real numbers and the number of el stored in the array. This function must display the elements of the array in order with each one on a line by itself in a field width of 7 with two decimal places. (See sample output. Recall the format specifier would be "%7.21f"). (b) Sometimes we want to treat an array as a mathematical vector and compute...
For this c++ assignment, Overview write a program that will process two sets of numeric information. The information will be needed for later processing, so it will be stored in two arrays that will be displayed, sorted, and displayed (again). One set of numeric information will be read from a file while the other will be randomly generated. The arrays that will be used in the assignment should be declared to hold a maximum of 50 double or float elements....