--Originally published at Let's CODE

--Originally published at Let's CODE
--Originally published at Programming Path
This quiz was veeeery long. There were 10 problems, but we only had to do 8 problems.
1. Escribe el función distancia cual recibe 4 números (x1, y1, x2, y2) cuales representan dos puntos en espacio (x1,y1) y (x2,y2). El método debe regresar la distancia entre los dos puntos. Recuerda que el valor cuadrada del hipotenusa del triangulo es igual que la suma de las cuadradas de los otro dos lados del triangulo (the hypotenuse squared is equal to the sum of the squares of the other two sides).
2. (5 puntos) Escribe un función que se llama triangulo cual recibe un parámetro size y imprime un triangulo derecho como el siguiente. El renglón mas grande debe llevar size numero de “T”. SOLO imprime los “T”s y los endlines. Nota que no hay characteres (espacios) a la derecha de los T’s. Debe usar un ciclo “for” para controlar el repetición.
3. Escribe la función factorial cual recibe un entero “x” y regresa el valor de x! Recuerda que 0! = 1, 1! = 1, 2! = 2, 3!= 6, 4! = 24, etc. Para los de Python: NO PUEDES usar el factorial como parte del module “math”
4. Escribe una función que se llama promedio_lista que recibe un parámetro (una lista (Python) o arreglo/Vector de C++) de valores float y regresa como float el promedio de los números en la lista.
5. Escribe una función que se llama smallest_of_four cual recibe cuatro valores float como parametros y regresa el minimo (más pequeño) de los valores. Ojo: puede recibir unos valores iguales.
Click to view slideshow.6. Escribe una función que se llama fibonacci cual recibe un número n (puedes dar por cuenta que valor mayor o igual que cero) y regresa y valor correspondiente del serie de fibonacci,
--Originally published at Programming Path
The assignment of the quiz was to ask for two coordinates and calculate the distance between them. It needed to have floats and a function as well.
This problem was very easy, because in school they made me calculate the distance a lot of times. I only add the math library (<cmath>) because I elevate to the power and resolve a square root.
Here is the code:
Thanks for reading.
--Originally published at Let's CODE
--Originally published at Programming
The instruction was:
Write a function that receives four parameters: x1, y1, x2, y2 which are all floating point values. The function is called distance and returns (float) the distance between x1,y1 and x2,y2 on the cartesian coordinate plane.
--Originally published at Programming
Fill out that survey here: http://url.kenbauer.me/midtermsurvey
The instruction was:
Write a function that calculates returns the “nth” Fibonacci number where we define a function over the Fibonacci numbers mapping the naturals (starting with zero) to the Fibonacci series. So fibonacci(0) returns 0, fibonacci(1) returns 1, fibonacci(2) returns 1 and so on. Note that we are using the modern definition where the sequence starts with zero. You should try to implement this with two solutions: one with a loop and one with recursion. Which do you think is “better”, which looks more “elegant”, which is more “efficient”?
--Originally published at my programming blog
( Photo credit to: Natalie Nichols)
Today I finished the quiz in the class!! Normally I finish the quiz during the day because I need to search for tutorials on how to do a code related to the quiz, or because I am completely lost! But this time with Ken’s explanation that the coordinates made a triangle I understood perfectly, also thanks to my project team that explained me the idea to make the code.
So the quiz was to ask the user for two coordinates (x1, y1, x2, y2) and then make a function that returns the distance between those two coordinates.
So first:
(I included the library cmath, to use the sqrt and the power function)
Here’s my code:
#include <iostream>
#include <cmath>
using
--Originally published at Let's CODE
--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:
--Originally published at my programming blog
Today I had to do the quiz #8 which was to create a function where I needed to calculate the nth number in the Fibonacci sequence. I had a lot of trouble with this quiz!!!!! I didn’t go to class, so I couldn’t ask to my classmates or to Ken, so I searched for a lot of examples and tutorials of different codes for this program and with what I understood I created my own program.
What I did was:
I hope you understand it! If not here are some examples of different codes and a tutorial that can give you an idea to create your own code. Also check the work of our classmates in