#WSQ10(Video)What the heck

Now this is more confusing, we must combine loops, functions, mathematical formulas, a few of all the topics we´ve seen until now.


This code will be completely different to the ones you´ve done before(talking abt myself) well, here´s the code posted on GitHub.

To beggin, add the usual library <iostream> and instead of using the “using namespace std” just determinate which of the parameters of the library you´ll use. Also add the <cmath> library because you must use it for the StandartDeviation part of the code.

The program must ask the user for 10 float values, counting and saving them using a variable in function of another, numbers[i]. Repeting the “for” loop as many times as you give the instructions to the program in the NUMOFNUM variable.

Now what? Well the code must have 3 functions(3 + the main) one, which will calculate the total addition of the numbers the users gave. Secondly, the average of the 10 numbers the user typed and finally, the standart deviation(I´ll explain a lot better in the video bellow what is it and how to get it).

Create the function for the total and in it, the program must do a loop to be adding the next value and to not write everything like(number[1]+number[2]+number[3]…etc.


In the next one, the average, you don´t have to add the numbers again, just call the last function and just divide it for the number of values(in this case 10) and there you go, you got the average. As you can see in this part of the code you don´t need to create a new loop, using the result of the addition function is all.


Now the third part, the standart deviation(yeah i know, you don´t even know what the heck that means haha me either so i had to make a quick research about it). Before you start typing like a crazy lol player, understand the concept and the formula, donpt worry m8, this video(in spanish) explains perfectly what the StandartDeviation means. (Click on the image to see the video.



Here´s the formula(its better explained in the video on the left or in my video bellow) Click on the formula to heard a nice song!


Pretty easy right? haha it is, X is the only value that changes with the loop. X(with a little hat or something like that idk) is the average. So you must get all the differences between the values and the average and raise every difference to the ^2. The next step is to add all the squares of the 10 differences. Next step, divie the number between the n(numbers of values) -1(in this case 10-1). Get the square root of it and there you go, you got the Standart Average. In my video I´ll make a example using the first 10 values(1,2,3…).

Here´s a quick video i made to explain all the stuff in spanish and to you to see how the program works.

And to end this majestic post i leave you here a pic of a guy serenading a sad cat that apparently lives in better conditions than me. And the most beautiful girl I´ve ever seen



7 respuestas a “#WSQ10(Video)What the heck


Introduce tus datos o haz clic en un icono para iniciar sesión:

Logo de WordPress.com

Estás comentando usando tu cuenta de WordPress.com. Cerrar sesión /  Cambiar )

Google+ photo

Estás comentando usando tu cuenta de Google+. Cerrar sesión /  Cambiar )

Imagen de Twitter

Estás comentando usando tu cuenta de Twitter. Cerrar sesión /  Cambiar )

Foto de Facebook

Estás comentando usando tu cuenta de Facebook. Cerrar sesión /  Cambiar )


Conectando a %s