--Originally published at The Talking Chalk
The Task
Create a program with a function that returns the factorial of the number given in the parameter.
The Process
The Code
#include <iostream>
#include <math.h>
using namespace std;
int main()
{
float number[10], sum, average, variance, sdev;
cout<<“Give ten numbers.”<<endl;
for(int counter = 0; counter<10; counter++)
{
cin>>number[counter];
sum+=number[counter];
average=sum/10;
variance+=pow(number[counter]-average, 2)/10;
sdev=sqrt(variance);
}
cout<<“The sum of the given numbers is: “<<sum<<endl;
cout<<“The average of the given numbers is: “<<average<<endl;
cout<<“The standard deviation of the given numbers is: “<<sdev<<endl;
return 0;
}
The topics
#For
#Arrays/vectors