THIS BLOGPOST IS NOT DONE YET, BUT STILL YOU CAN ALREADY TAKE A LOOK AT THE CODE, WHICH IS AT THE END. For the task number ten of the semester, we were asked to create program that asks the user for 10 numbers. We were required to store those numbers in a list and to show the user the total, average and standard deviation of those numbers.
The easiest way to this was to create an array for those numbers. An array is just a group of numbers saved by the computer. You can acces any of those numbers
#include <iostream>
#include <cmath>
using namespace std;
int y;
char answer;
float SumaTotal(float arre [], int numNumeros){
float sum = 0;
for (int i = 0; i < numNumeros; i++){
sum += arre[i];
}
return sum;
}
float Average (float arra[], int numas){
float aver, suma = 0;
for (int c = 0; c < numas; c++){
suma = suma + arra[c];
}
aver = suma / numas;
return aver;
}
float STDF (float arre[], int numdenum){
float aver, sumaII, sumaIII = 0,sumaI = 0;
double stdfi;
for (int c = 0; c < numdenum; c++){
sumaI += arre[c];
}
aver = sumaI / numdenum;
for (int i = 0; i < numdenum; i++){
sumaII = arre[i] – aver;
sumaIII += pow((sumaII), 2);
}
stdfi = sqrt((sumaIII / numdenum ));
return stdfi;
}
int main (){
do{
cout << “Type the number of numbers that you want to have: “;
cin >> y;
const int numNumbers = y;
float x [numNumbers];
for (int i = 0; i < numNumbers; i = i + 1){
cout << “Provide the number ” << i + 1 << ” number: “;
cin >> x [i];
}
cout << “The total of your numbers is:
Continue reading “Standard deviation calculator” →