Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <math.h>
- using namespace std;
- int main() {
- unsigned int N = 0;
- float Sum = 0, SquaredSum = 0, Input;
- cout << "Enter each of your numbers on a new line. Ctrl-Z or EOF marker to terminate." << endl;
- while (cin >> Input) {
- N++;
- Sum += Input;
- SquaredSum += (Input * Input);
- }
- float Mean = Sum / (float)N;
- float StdDev = sqrt((SquaredSum - ((float)N * Mean * Mean)) / (float)(N-1));
- cout << "Mean = " << Mean << endl
- << "Standard Deviation = " << StdDev << endl;
- return 0;
- }
Add Comment
Please, Sign In to add comment