#include<iostream> #include<iomanip> #include<cmath> using namespace std; //function prototype int AVSD(double[], double&, double&, const int); int max; int main() { const int SIZE = 10; int index = 0; double average = 0, SD = 0; double studyHour[SIZE] = {10,16,15.65,17,16.3,20,10.5,17.5,12 }; index = AVSD(studyHour, average, SD, SIZE); cout << "Details of Practical Group 1" << endl; cout << "Average:" << average<<endl; cout << "Standard Deviation:" <<SD<< endl; cout << "Highest study hour" <<studyHour[max]<<endl; system("PAUSE"); return 0; } int AVSD(double studyHour[], double& average, double& SD, const int SIZE) { double sum = 0; for (int i = 0; i < SIZE; i++) { sum = sum + studyHour[i]; average = sum / SIZE; } double total = 0; for (int i = 0; i < SIZE; i++) { pow((studyHour[i] - average), 2); total += pow((studyHour[i] - average), 2); } SD = sqrt(fabs(total / SIZE)); for (int i = 0; i < 10; i++) { if (i == 0) { max = i; } else { if (studyHour[i] > studyHour[max]) max = i; } return max; } }
using namespace std;
int max;
std
std::max
max
using
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)