Advertisement
Guest User

Untitled

a guest
Jan 17th, 2017
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. #include <iostream>
  2. #include <math.h>
  3.  
  4. using namespace std;
  5.  
  6. int main() {
  7. int n;
  8. cout << "Amount of operations:";
  9. cin >> n;
  10.  
  11. int xi;
  12. float EX, p, result = 0;
  13.  
  14. cout << "Provide EX:";
  15. cin >> EX;
  16.  
  17. for(int i = 0; i < n; i += 1) {
  18. cout << "\nStep " << i + 1 << endl;
  19. cout << "Provide current x:";
  20. cin >> xi;
  21. cout << "Provide current p:";
  22. cin >> p;
  23.  
  24. result += pow((xi - EX), 2) * p;
  25. }
  26.  
  27. cout << "\nVar(X) = " << result;
  28. cout << "\nD(X) = " << sqrt(result);
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement