Write a C++ program that reads a set of floating-point data values. Use a sentin
ID: 1931350 • Letter: W
Question
Write a C++ program that reads a set of floating-point data values. Use a sentinel-controlled while loop to end entering data values. When all values have been read, print out the count of the values, the average, and the standard deviation. Use the following formula for calculating standard deviation.
Explanation / Answer
#include #include using namespace std; int main(){ char wait; float sumx=0,sumxx=0,input,S,s,avg; int n=0; coutinput; while(input!=-999999){ n++; sumx+=input; sumxx+=pow(input,2); cin>>input; } avg=sumx/n; S=sqrt(((n*sumxx)-(pow(sumx,2)))/(n*(n-1))); //think that this formula is wrong ..., but is according to your formula :/ //should be this? s=sqrt(((sumxx/n)-(pow(avg,2)))); coutRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.