### Standard Deviation

How exactly do you use this formula?

sdx = sqrt((sumx2 - (sumx * sumx)/n)/(n-1)

I was told to use that formula in my program but I don't understand how it works could anyone explain it to me please.
I figured out I need header to use the function sqrt.
 ``1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374`` ``````#include using namespace std; void Display_Menu(); int main () { Display_Menu(); int choice,grad,count,sum; int min = 100; int max = 0; cin >> choice; while (choice != 'q') { if (choice == 1) { while (grad >= 0) { cout <<"Enter the necessary grades.\n"; cin >>grad; if (grad >=0) { sum = sum + grad; count++; } if (grad 0) { min = grad; } if (grad > max) { max = grad; } } cout << min; cout <<"Enter you're next choice.\n"; cin >> choice; } if (choice == 2) { int average; average = sum/count; cout << "This is the average of the grades entered.\n" << average << "\n"; cout << "Select you're next choice.\n"; cin >> choice; } if (choice == 3) { } if (choice == 4) { cout << "This is the highest grade you entered.\n" << max << "\n"; cout << "This is the lowest grade you entered.\n" << min << "\n"; } cout << "Goodbye see you next time.\n"; break; } system ("pause"); return 0; } void Display_Menu() { cout << " Option 1 : Enter grades ( Quit with a negative value)\n"; cout << " Option 2 : Display the Mean(average) for the grades\n"; cout << " Option 3 : Display the standard deviation for the grades\n"; cout << " Option 4 : Display the high and low grades\n"; cout << " Option 5 : Enter 'q' to quit\n"; cout << "Enter you're choice (1-5)\n"; }``````

I need to add the above standard deviation formula in my choice ==3 but I am not sure how the formula works. Sorry if the program looks messy I am trying to figure out how to do it first before actually cleaning it up.
Topic archived. No new replies allowed.