Lists!

--Originally published at my programming blog

The assignment of last week was to ask the user for 10 values and then calculate the standard deviation with those values, then you needed to change your program so that the user could tell you how many values he wanted to enter.

It was easy to calculate the standard deviation when you ask the user for 10 values, but when I wanted the user to tell me the size of the array I had a lot of problems.

This is what I did:

  1. First I did my function and in the parameters I included the array and the integer size (which is the size the user will enter).
  2. Then I declared my values which were floats, sum=0, average, sum2=0 and SD
  3. Then I did a for loop where while i was less than the value of size there will be a sum of values.
  4. Then that sum that was calculated I divided it by the integer size to calculate the average.
  5. Then I did another for loop where when i was less than the size, then there will be a sum2 that will be equal to the sum of the  first value entered minus the average and that to the power of 2, (so you need to include the cmath library).
  6. Then I equaled SD to the sum2 divided bye the size of the array, and my function will return SD.
  7. In my int main I declared the integer size and I asked the user for the value of size.
  8. Then I declared my array with the value inside the brackets “size”. So that the program knows that the size of my array is equal to the size entered by the user.
  9. Then I asked the user for the values and I did a for loop where while i
    screen-shot-2017-03-06-at-10-39-48-am
    screen-shot-2017-03-06-at-10-40-01-am
    screen-shot-2017-03-06-at-10-40-58-am
    Continue reading "Lists!"

#WSQ07 Lists 03/03/17 and WSQ07.cpp

--Originally published at Solving Problems with Programming

PICTURE OF ACTOR

So in this eight week class I started with doing the survey of mid semester where I gave ideas in order to improve this course and this and this WSQ07. I started reviewing in creating and calling functions in C++. #Mastery06, #Mastery07, #Mastery16 Use of recursion for repetitive algorithms, #Mastery17 When to use what type of repetition in a program and #Mastery18 Creation and use of Arrays/ Vectors in C++.

What I did for this numeric program is solving the problem to the user by writing 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.Futhermore, Once you have this working, change it so that users keep giving you values until they signal “no more values”. How would you implement this and in particular for the C++ group, how to you deal with an unknown size to your array during compilation?

The quantity of the value depends of the quantity of the type float variable that has only 32 bits of leght, therefore you need a new library in order to increase the value of numbers called Biginteger.hh but I am going to add it in the next WSQ08 called Yo soy 196. Next, to deal with an unknown size of my array during compilation we need to ask the user the number of that size and save it in a variable n.

The resources I need it to solve this program are here:

ken bauer

Similar code made by Eduardo Torres

C Programming Tutorial: Functions (Call By Value, Reference,passing Arrays to function)

The following photograph shows the solution to this problem:

wsq7v2

wsq7v3

wsq7v4wsq7v5

wsq7v6

Picture of author

So at first I wrote the same structure of the program just did the same as

s1
s2
s3
s4
s5
Continue reading "#WSQ07 Lists 03/03/17 and WSQ07.cpp"

Suma, promedio y desviación estandar… Todo en uno!!!!(WSQ07)

--Originally published at Hensel

Este programa calcula el promedio, la suma y la desviación estándar de un determinado numero de datos que ingresa el usuario, en este caso son diez datos, para calcular el promedio solo basta con sumar todos los datos y dividir el resultado entre el numero de datos sumados. Para la desviación estándar, se requiere elevar cada termino al cuadrado, sumar todos los cocientes, dividir el resultado final entre el numero total de datos ingresados y sacarle raíz cuadrada.

Wsq07(1).jpeg

Para esta primer parte, agregue la librería cmath para realizar algunas operaciones matemáticas mas adelante. Decidí crear tres funciones, una para cada operación a realizar. Como ven la primera es promedio, la segunda es suma y la tercera es la de desviación estándar. en la función para calcular la desviación estándar usamos la librería cmath para poder calcular la potencia de dichos números y sacar la raíz cuadrada. NOTA : acabo de ver que mi código tiene un pequeño error, tal vez surgió al tomar la fotografía, el error se encuentra en la función de la desviación estándar al final de la línea R=…… antes del (;) tenemos este signo (-), el cual causa un error, solo basta con eliminarlo y listo.

 

Wsq07(2).jpeg

En la segunda parte de mi código, declaramos las variables como locales y desplegamos una serie de mensajes para que el usuario ingrese cada uno de los datos, al final llamamos a las funciones correspondientes para cada resultado y lo muestra en pantalla.

Wsq07(3).jpeg

Finalmente, vemos el resultado de nuestro código le pide al usuario ingresar el primer dato, después el segundo y así sucesivamente hasta el décimo, para entregarnos los resultados.


List…

--Originally published at Loading…

Activity:

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.

This one was a little difficult because I didn’t know NOTHING about arrays or vectors in C++, that’s the reason why I didn’t submit nothing in the las 2 weeks. No matter how much I read or investigate in the book or internet, I didn’t understand how it works, until I found this classmate’s post and it was like the illumination for me. So, this is my code:

list

First I added the library <cmath> for the program recognize the operations. Then in my int main, I established my variables as float, and to make the list I used an array, for this you put a name, in my case “list”, then add the [ ] and in the middle you establish how many numbers you want to store, in this activity we want to store 10. The rest is ‘easy’ you just need to be careful in the operations, pow is a function of exponents and for the rest I think it doesn’t needs much explanation, anyway if you have any question you can leave a comment and I’ ll answer you. I hope I was able to help you.

This is how it works:

list02


Stepping up the game

--Originally published at Ken&#039;s Disciple 01

Picture by Negative Space Negative Space

 

Hello everyone and welcome to my WSQ07 Blog. Well here’s where I found a little more challenging tasks, so we have to really start trying things and doing a little research if we want things to go well.

WSQ07 was more complicate for me because I’ve never seen vectors or arrays, which are the main things that we’ll need for this assignment. What we had to do was: 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. For the final part, we had to make our program work not for only 10 numbers, but for ‘n’ numbers.

NOTE: I made this program with arrays, so if you want to check it with vectors you may want to check someone else’s Blog, reading the chapter of the book about vectors etc.

You may want to check this things before trying to do the program:

  • I started reading again our book, and as ken says it’s actually useful, not only for this topics, but for all our programming in general, I swear It’ll help you a lot, it’ll make things easier.
  • Super useful information about arrays that may not be found in our book:
    Arrays
    Declare array without specified size
  • You’ll need cmath library for doing the standard deviation (you don’t need it by force but it’s easier).
  • Remember your for conditions and really, READ THE BOOK.

 

As you saw from the links I gave you about arrays, you have to declare it first, we leave it alone because we don’t know the amount of spaces (numbers) we’ll need, actually the user will give us that information. Then, inside the main you may

stdev
Captura de pantalla 2017-02-28 a la(s) 11.02.55.png
captura-de-pantalla-2017-02-28-a-las-11-04-14
captura-de-pantalla-2017-02-28-a-las-11-03-58
captura-de-pantalla-2017-02-28-a-las-11-03-23
Continue reading "Stepping up the game"

Homework 7: Lists

--Originally published at Let&#039;s CODE

This program will ask the user for 10 numbers and will be stored in a vector. Then, the user will be able to see the total of the sum, average and standard deviation of those numbers. A vector is very easy to use, you have to asign a type to the vector and give it … Continue reading Homework 7: Lists

Lists :)

--Originally published at My life @ TEC

Hi! it’s me again, ok so in this program what we did is that we asked the user for 10 numbers and we give them the total, the average and the standard deviation. Honestly this was hard, I didnt know how to do it, but I learned the “for” loop, so that is good, I’m learning new ways to program.

here’s my code

#include
#include using namespace std;
int main (){
float lists[10], sum=0, average, stdev1=0, stdev, stdev3;
cout<<“hey! please give me 10 numbers”<<endl;
for (int i=0; i<10; i++){ cin>>lists[i];
sum=sum+lists[i];
}
average=sum/10;
for(int i=0; i<10; i++){
stdev+=pow(lists[i]-average,2);
}
stdev=sqrt(stdev/(10-1));
cout<<“the total is “<<sum<<“, the average is “<<average<<” and the standard deviation is “<<stdev<<endl;
return 0;
}

and here’s how it works:

lists


WSQ07 – Lists lml

--Originally published at Programming the city

Hello there!

As usual, I post my codes here in programmingthecity, I really like the way we work in the course TC1017.

Well, this program was difficult for me, because I didn’t know how to make the lists, neither the arrays, but with the help of my teacher I could finally did it.

For advice, just be careful when making the lists and the math operations.

Here is the code.

wsq07

 

And the result is here.

wsq07

 

You can see these web pages helped me with the code.

 

https://www.programiz.com/cpp-programming/examples/standard-deviation


Números, en lista, Ya!

--Originally published at Adal´s Blog



O era actividad ???


En el libro viene una sección donde explican lo básico pero necesario para saber que son los arreglos, con esa información y un apartado de la aplicación Aprende C++ pude hacer el ejercicio
 Paginas de ayuda: