Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <math.h>
- using namespace std;
- int main() {
- int n;
- cout << "Amount of operations:";
- cin >> n;
- int xi;
- float EX, p, result = 0;
- cout << "Provide EX:";
- cin >> EX;
- for(int i = 0; i < n; i += 1) {
- cout << "\nStep " << i + 1 << endl;
- cout << "Provide current x:";
- cin >> xi;
- cout << "Provide current p:";
- cin >> p;
- result += pow((xi - EX), 2) * p;
- }
- cout << "\nVar(X) = " << result;
- cout << "\nD(X) = " << sqrt(result);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement