Guest User

Untitled

a guest
May 7th, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. #include <iostream>
  2. #include <math.h>
  3. using namespace std;
  4.  
  5. int main() {
  6. unsigned int N = 0;
  7. float Sum = 0, SquaredSum = 0, Input;
  8.  
  9. cout << "Enter each of your numbers on a new line. Ctrl-Z or EOF marker to terminate." << endl;
  10. while (cin >> Input) {
  11. N++;
  12. Sum += Input;
  13. SquaredSum += (Input * Input);
  14. }
  15.  
  16. float Mean = Sum / (float)N;
  17. float StdDev = sqrt((SquaredSum - ((float)N * Mean * Mean)) / (float)(N-1));
  18. cout << "Mean = " << Mean << endl
  19. << "Standard Deviation = " << StdDev << endl;
  20. return 0;
  21. }
Add Comment
Please, Sign In to add comment