WSQ 07

Create a program that asks the user for 10 numbers  (floating point). Store those numbers in a list. Show to the user the total, average and standard deviation of those numbers.

Before we get started, let’s define the average and the standard deviation.

  1. Standard deviation: Is a measure that is used to quantify the amount of variation or dispersion of a set of data values. (Source: https://en.wikipedia.org/wiki/Standard_deviation)
  2.  Average: Is the sume of all the elements of a list divided by the number of elements.Captura de pantalla 2017-05-07 a la(s) 19.55.45

    code:#include <iostream>
    #include <math.h>
    using namespace std;

    int main(){
    float numeros [10];
    float suma =0, prom =0, desv, desv1;
    cout << “Introduce 10 numeros para saber la suma, el promedio, y desviación estandar: ” << endl;
    for (int i =0; i <10; i++){
    cin >> numeros[i];
    suma += numeros[i];
    }
    prom = suma/10;
    for (int i =0; i < 10; i++)
    desv += pow((numeros[i] – prom),2);
    desv1 = sqrt(desv/9);
    cout << “\nLa suma es: ” << suma;
    cout << “\nEl promedio es: ” << prom;
    cout << “\nLa desviacion estandar es: ” << desv1;
    return 0;
    };

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s