Answer to Question #5270 in C++ for aimelawan
1. Make a program that calculates the average and standard deviation of marks of 10 students. Note that you cannot use 10 input variables. You should use loops for the purpose.
float a, ave, dev;
& cout<<"Enter a mark of student "<<i+1<<": ";
ave = 0;
for (i=0;i<=9;i++) ave = ave + a[i];
ave = ave/10;
dev = 0;
for (i=0;i<=9;i++) dev = dev + (a[i]-ave)*(a[i]-ave);
dev = sqrt(dev/10);
cout<<"Average is "<<ave<<"\n"<<" Standard deviation is "<<dev;
No comments. Be first!