Created
October 27, 2017 21:59
-
-
Save jesuscmadrigal/956ffe1277dfecb0e542977c845cd5ef to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <cmath> | |
using std::cout; | |
using std::cin; | |
using std::endl; | |
float total(float array[],int size){ | |
float sum = 0.0; | |
for (int i=0;i<size;i++){ | |
sum=sum+array[i]; | |
} | |
return sum; | |
} | |
float average(float array[], int size){ | |
float avg=total(array,size); | |
avg= avg/size; | |
return avg; | |
} | |
float derivation(float array[],int size){ | |
float derivation = 0.0; | |
float avg = average(array,size); | |
for (int i=0;i<size;i++){ | |
derivation=derivation+((array[i]-avg)*(array[i]-avg)); | |
} | |
return derivation; | |
} | |
float standardderivation(float array[],int size){ | |
float std; | |
std=sqrt((derivation(array,size))/size); | |
return std; | |
} | |
int main(){ | |
float array [10]; | |
for(int i=0;i<10;i++){ | |
cout << "Please enter a number" << endl; | |
cin >> array[i]; | |
} | |
cout << "the sum of those numbers is: " << total(array,10) << endl; | |
cout << "the standard derivation of those numbers is: " << standardderivation(array,10) << endl; | |
cout << "the average of those numbers is: " << average(array,10) << endl; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment