--Originally published at PZ
Its the perfect moment to start working with arrays and vector, both are amazing topics that will help me a lot in the future, because it is imposible to make a programm with a huge amount of numbers with out arrays or vectors.
To be honest I didnt know what both of the are, before doing this work, but when I start researching in YouTube I discovered that this was an amazing topic. I watched this video to understand the topic https://www.youtube.com/watch?v=gCBpGyKyaGU.
Then I searched on how to use standar deviation and I watched this video https://www.youtube.com/watch?v=jMOwnFXz2lc, in this video I also understand on how to use the library math which can be very helpful in the future, even in physics.
Code
#include <iostream>
#include <math.h>
using namespace std;
int main()
{
int size = 10;
float numbers[size];
float suma,prom,desv,varianza;
cout << “Please enter up tp 10 positive numbers.” << endl;
for (int i=0; i < size; i++)
{
cin >> numbers[i];
}
cout << endl;
for (int i=0; i < size; i++)
{
suma += numbers[i];
prom = suma/size;
}
for (int i=0; i < size; i++)
{
cout << “Los numeros elegidos son ” << numbers[i]<<endl;
}
for (int i=0; i < size; i++)
{
varianza=varianza+pow((numbers[i]-prom),2);
}
desv=sqrt(varianza/(size-1));
cout<<“La suma de los numeros es: “<<suma<<” el promedio es: ” <<prom<<” la desviacion es “<<desv<<endl;
return 0;
}