Time to tame the beast 😈

This quiz was another level. I found it difficult because of the Fibonacci series, but at the end I tamed the beast.

In this quiz we had to :

  1. Write a function called distance(x1, y1, x2, y2) which receives four numbers which
    represent two points in the cartesian plane. The function should return the distance
    between the two points (x1,y1) and (x2,y2). Remember that the square of the
    hypotenuse of a right angle triangle is equal to the sum of the squares of the two other sides.
  2. Write a function called fibonacci which receives a single parameter “n” (a non-negative integer) and returns the nth number in the fibonacci series which is:
    0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89…………
    So, fibonacci(0) would return 0.
    fibonacci(5) would return 5
    fibonacci(8) would return 21.
    Note that the first two fibonacci numbers are 0 and 1.
    All others are the sum of the previous two fibonacci numbers.

1288910_700b

             (Credits goes to http://9gag.com/gag/1288910)

 

This was me with the Fibonacci program, beacuase in my other course I used to have a lot of problems, but at the end  I tamed the beast. 🐯

The link to meet the beast 👉 https://github.com/mfcanov/Quiz-3.git

 

QUIZ#3

quuiz3

quiz3
#1. Este es un programa para calcular la distancia entre dos puntos de coordenadas. Para esto debemos conocer que la formula de distancia entre dos puntos es la raiz de (x2^2-x1^1)+(y2^2-y1^1) . Conociendo esta formula hay que pedirle al usuario esas 4 variables. Para esto se hace una función que nos pide se llame distancia pidiendo como float (porque pueden ser en decimales) las coordenadas, donde la operación que nos regresará es la de distancia entre dos puntos. En el main se ve como se piden las variables y al final se manda llamar la función, para obtener el resultado.
quuuiz3
Se realizó la operación siendo la razi de ((5)^2-(3)^2+(6)^2-(4)^2)=2.82843
quuuuiz3
#2. Este es un programa para calcular el fibonacci de un numero. En este programa se hace una función llamada fib donde sabemos que solo es con una variable pues es de un numero en el que se tiene que meter un if dentro de la función pues se ira ciclando mientras n sea menos o igual a 1 y nos regresa n La función nos va a regresar fib(n-1)+fib(n-2) pues es la operación debido a que lo que va a haciendo es esto 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89 dado que si decimos el fibonacci del numero 9 es el 34 y así. En el main va de nuevo la variable que le pides al usuario y se manda llamar a la funcion.
fibonacci
Ahí esta compilado y se ve el fibonacci del numero 9. que es igual a 34.

Quiz 3

Hey there, here is my quiz 3 results and solution, the instructions where the following ones:

  1. Write a function called distance(x1, y1, x2, y2) which receives four numbers which represent two points in the cartesian plane. The function should return the distance between the two points (x1,y1) and (x2,y2).
  2. Write a function called fibonacci which receives a single parameter “n” (a non-negative integer) and returns the nth number in the fibonacci series.

Here I leave you a link to the quiz: QUIZ3

For the first one, here I leave you all the pictures:

Click to view slideshow.

You can get access to the code in the following link:

https://gist.github.com/batmantec/03e91eda0605eef62746

For the second one, it actually took more research, because I didn’t understand what is the sequence that the Fibonacci use, for it I consult a lot of websites, which I will list here.

http://www.maths.surrey.ac.uk/hosted-sites/R.Knott/Fibonacci/fib.html

https://en.wikipedia.org/wiki/Fibonacci_number

http://platonicrealms.com/encyclopedia/Fibonacci-sequence

At the end, It was really weird how I did manage to make it, but It did gave me the results I was hoping for.

Here I leave you some pictures of the code and the program running:

Click to view slideshow.

The link to the code is here:

https://gist.github.com/batmantec/3ab093f33ee801a6fbdf

⁄⁄⁄⁄⁄⁄⁄⁄⁄⁄Quiz3⁄⁄⁄⁄⁄⁄⁄⁄⁄⁄

Photograph credit

Hi guys, you know I always make a video about wsq’s and quizzes. This time we had to make two programs in quiz 3, the distance program and the fibonacci program. Well I decided not to make a video about the distance program because it’s really not that difficult, instead I made a video about the two ways to make the fibonacci program. First I explain how to do it wit recursion and then with loops. Be sure to take a look at Ernesto’s Blog too

Alexhfoo’s blog: This guys blog is pretty cool, check it out.

Link to the Quiz

code:

Distance.cpp

Fibonacci.cpp

FibLoop.cpp

FibRecur.cpp

Ok for the Distance program I used these images to help visualize what is going on:

imagesimages

As you can see, that line is the distance we want to know, it is the hypotenuse if you look at the picture as a right triangle. So in our program we obviously have to use a squared function and a square root function. Those are pow() and sqrt() respectively. I got these functions from here. It is pretty simple, take a look at my program so you can see one way of doing it.

Here is the video about recursion

And here is my tutorial.

Made by Orlando Lara