Advertisement
Guest User

Untitled

a guest
Mar 27th, 2015
195
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.26 KB | None | 0 0
  1. #include "stdafx.h" //No Flipping Clue
  2. #include <iostream> //Needed For "cout"
  3. #include <iomanip> //Needed To Round Decimal Points
  4. #include <math.h> //Needed For "sqrt()" And "pow()"
  5.  
  6. using namespace std;
  7.  
  8. int _tmain(int argc, _TCHAR* argv[])
  9. {
  10. //Used To Round The Decimal Points 2 Places
  11. cout << setiosflags(ios::fixed|ios::showpoint);
  12. cout << setprecision(1);
  13.  
  14. //Declaring
  15. double Numbers[] = {65, 49, 74, 59, 48}; //Work On Making This A User Input
  16. double Mean = 0, Items = 0, Sum = 0, Deviation = 0;
  17. int Counter;
  18.  
  19. //Finds The Mean Of The Set Of Numbers
  20. for (Counter = 0; Counter < (sizeof(Numbers) / sizeof(double)); Counter++)
  21. {
  22. for (Counter = 0; Counter < sizeof(Numbers) / sizeof(double); Counter++)
  23. {
  24. Sum += Numbers[Counter]; //Adds All Numbers In Array Together
  25. }
  26. Items = sizeof(Numbers) / sizeof(double); //Gets The Number Of Items In The Array
  27. Mean = Sum / Items; //Finds The Mean
  28. }
  29.  
  30. //Finds The Standard Deviation
  31. for (Counter = 0; Counter < sizeof(Numbers) / sizeof(double); Counter++)
  32. {
  33. Deviation += pow((Numbers[Counter] - Mean), 2) / Items; //Does Math Things...
  34. }
  35. Deviation = sqrt(Deviation); //Square Roots The Final Product
  36. cout << "Deviation = " << Deviation << endl; //Print Out The Standard Deviation
  37.  
  38. system("pause");
  39. return 0;
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement