On line 20 and 29, it says:
'av' was not declared in this scope
And on line 30, it says:
's' was not declared in this scope
What's the problem?
#include <iostream>
#include <cmath>
using namespace std;
const int SIZE= 6;
int nums[SIZE]= {1,5,6,43,7,9};
int average(double av){
//av is to get the average of the array
int sum=0;
for (int i=0; i<SIZE; i++){
sum+= nums[i];
av= static_cast<double>(sum/SIZE);
}
return av;
}
int deviation( double s ){
int function = nums[0]-average(av);
int nominator = pow(function, 2);
s = sqrt(nominator/SIZE);
return s;
}
int main(){
cout << "Numbers: "<< nums[SIZE]<< endl;
cout << "Average: "<< average(av)<<endl;
cout << " Standard Deviation: "<< deviation(s)<<endl;
}