0

```
#include <iostream>
#include <cmath>
using namespace std;
int n;
void main(){
cout<<"input the number of students: ";
cin>>n;
double *scores= new double[n];
cout<<"enter the scores of the students: ";
for( int i=0; i<n; i++){
cin>>scores[i];
}
double sigma,sigma2, mean, strDev;
int ii;
for (sigma=ii=0;ii<n;ii++){
sigma+=*scores;
*scores++;
mean= sigma / n;
}
int iii;
for (sigma2=iii=0;iii<n;iii++){
sigma2+=pow(*scores-mean,2);
*scores++;
}
cout<<"The mean is: "<<mean<<endl;
strDev= pow(sigma2/n,1/2);
//cout<<"The standard deviation is: "<<strDev<<endl;
cout<<sigma2<<endl;
cout<<sigma2/n<<endl;
cout<<*scores<<endl;
}
```

Hello everyone, I have some quick questions about my code. First of all, I created this 1-dimensional dynamic array where the user can input the number of people in the class and their grades. The problem I'm having right now is that the standard deviation is not working correctly. When I put that there are 5 people (n=5) and that their scores were 1,2,3,4,5, the mean comes out right, but sigma2 which i need for finding out the standard deviation comes to to 45 when it should be 10. Can someone please tell me what is wrong with it?