Advertisement
Guest User

Untitled

a guest
Feb 23rd, 2019
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.18 KB | None | 0 0
  1. //
  2. // main.cpp
  3. // project6
  4. //
  5. // Created by . on 10/21/12.
  6. // Copyright (c) 2012 baldurt. All rights reserved.
  7. //
  8.  
  9.  
  10.  
  11. #include <iostream>
  12. using namespace std;
  13. const int num=0, i=0;
  14. double stdDev(double array[], int size);
  15. double average(double array[], int size);
  16. int main()
  17. {
  18. double array[10];
  19. double stdDeviation;
  20. char ans;
  21. int num;
  22.  
  23. do
  24. {
  25. cout << "Enter desired amount of numbers/n";
  26. cin >> num;
  27.  
  28. for (int i = 0; i < num; i++)
  29. {
  30. cin >> array[i];
  31. }
  32.  
  33. cout << "Enter values, separated by white space/n" << "Do you want to continue (Y/N)?\n";
  34. cin >> ans;
  35.  
  36. } while(ans == 'y' || ans == 'Y');
  37.  
  38. return 0;
  39.  
  40.  
  41. double stdDev(double array[], int size)
  42. {
  43. double sumSquares = 0;
  44. double avg = average(s, size);
  45.  
  46. for(int i = 0; i < size; i++)
  47. sumSquares += (s[i] - avg) * (s[i] - avg);
  48.  
  49. return sqrt(sumSquares / size);
  50.  
  51.  
  52. double average(double s[], int size)
  53.  
  54. double sum = 0;
  55.  
  56. for(int i = 0; i < size; i++)
  57. sum += s[i];
  58.  
  59. return sum / size;
  60. };
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement