Oops! It appears that you have disabled your Javascript. In order for you to see this page as it is meant to appear, we ask that you please re-enable your Javascript!

Program to Evaluate Standard Deviation by passing it to function in CPP (C plus plus)

Program to Evaluate Standard Deviation by passing it to function in CPP (C plus plus)

In this tutorial, we will learn about the Program to Evaluate Standard Deviation by passing it to function in CPP (C plus plus).

#include <iostream>
#include <cmath>

using namespace std;

float cal_SD(float data[]);

int main()
{
    float info[10];
	int k;
    
    cout<<"Please enter any 10 elements: ";
    
    for(k=0;k<10;++k)
        cin >> info[k];

    cout<<endl<<"Standard Deviation= "<<cal_SD(info);

    return 0;
}

float cal_SD(float data[])
{
    float mean;
	float add=0.0;
	float SD=0.0;

    int k;

    for(k=0; k<10; ++k)
    {
        add+= data[k];
    }

    mean = add/10;

    for(k=0; k<10; ++k)
        SD+= pow(data[k] - mean, 2);

    return sqrt(SD/10);
}

Output:

Program to Evaluate Standard Deviation by passing it to function in CPP (C plus plus)

Program to Evaluate Standard Deviation by passing it to function in CPP (C plus plus)