Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //
- // main.cpp
- // project6
- //
- // Created by . on 10/21/12.
- // Copyright (c) 2012 baldurt. All rights reserved.
- //
- #include <iostream>
- #include <cmath>
- using namespace std;
- const int num=0, i=0;
- double stdDev(double s[], int size);
- double average(double s[], int size);
- int main()
- {
- double array[i];
- double stdDeviation;
- char ans;
- int num;
- do
- {
- cout << "Enter desired amount of numbers/n";
- cin >> num;
- for (int i = 0; i < num; i++){
- cin >> array[i];
- }
- cout << "Enter values, separated by white space" << endl;
- for(int i = 0; i < array[i]; i++){
- cin >> [i]
- stdDeviation = stdDev(array[i]);
- cout << "The Standard Deviation is: "
- << stdDeviation << endl;
- cout << "Do you want to continue (Y/N)?\n";
- cin >> ans;
- } while(ans == 'y' || ans == 'Y');
- return 0;
- double stdDev(double s[], int size)
- {
- double sumSquares = 0;
- double avg = average(s, size);
- for(int i = 0; i < size; i++)
- sumSquares += (s[i] - avg) * (s[i] - avg);
- return sqrt(sumSquares / size);
- double average(double s[], int size)
- {
- double sum = 0;
- for(int i = 0; i < size; i++)
- sum += s[i];
- }
- return sum / size;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement