Quiz 6 Euclides In this quiz we had to make a program that tells you the greatest common divisor between two integer numbers. So the program asks for the biggest number and then the smallest.

For this we have to use the Euclid’s Algorithm: (Wikipedia obviously)

The Euclidean algorithm is based on the principle that the greatest common divisor of two numbers does not change if the larger number is replaced by its difference with the smaller number. For example, 21 is the GCD of 252 and 105 (252 = 21 × 12 and 105 = 21 × 5), and the same number 21 is also the GCD of 105 and 147 = 252 − 105. Since this replacement reduces the larger of the two numbers, repeating this process gives successively smaller pairs of numbers until one of the two numbers reaches zero. When that occurs, the other number (the one that is not zero) is the GCD of the original two numbers.

Here is a video, it´s in Spanish but explains this quite good:  Thanks to Baruch who taught me how to make the loop.   WSQ 10 List of Numbers

In this WSQ I had to create a program that ask for numbers and then show them as a list, the total, average and standard deviation of them.

So I used a for loop with a array to ask for the numbers, the array was the quantity of numbers I would like to use for that program, so I could modify it for whatever I want to.

Then, I created the functions Total, Average and Std. Dev., the Total function could be used for the Average and the Average could be used for the Standard Deviation. When it runs looks like this: As you can see, this is an “easy” program but you have to make it easy to write, using functions, loops and arrays. TC101

WSQ10  Quiz 3

Now we have the Quiz number 3.

In this quiz, first we have to create a program that calculates the distance between two point in a graph using the coordinates (X, Y).

The user has to introduce the two points (X1, Y1) and (X2, Y2).  In the second program we have to do the Fibonacci sequence using just one input.

The Fibonacci sequence are the numbers in the following integer sequence.

0, 1, 1, 2, 3, 5, 8, 13, 21, …

By definition, the first two numbers in the Fibonacci sequence are either 1 and 1, or 0 and 1, depending on the chosen starting point of the sequence, and each subsequent number is the sum of the previous two. Also, the program ask the user if he wants another number of the sequence.  TC101

Quiz 3  WSQ09 Factorial

In this program we have to make a loop in which we find the factorial number of the one ingress by the user. Then we have to ask if he wants to ingress another number to calculate the factorial.

The factorial function (symbol: !) means to multiply a series of descending natural numbers. Example:

• 4! = 4 × 3 × 2 × 1 = 24

I´m going to use a For loop to make the factorial inside a Do-While loop to ask if he wants another number.  The code will be here at GitHub

Greetings! TC101

WSQ09  WSQ08 Functions

The functions allow to structure programs in segments of code to perform individual tasks.

In this program I´m going to do the same as in the WSQ03, but using functions.

You have to enter two numbers and the program will calculate:

• The difference of the two numbers.
• The product of the two numbers.
• The integer based division of the two numbers (so no decimal point). First divided by second.
• The remainder of integer division of the two numbers.   I will leave the code on GitHub, here is the link. TC101

WSQ08  QUIZ 2

In this Quiz we just had 2 exercises:

In the first exercise we had to ask for two numbers (a, b) and show the result of growing the first one to the second one. Example: (a=5, b=2) R=25
We could do this with the function Pow including the <math.h> library, or we can do it with the function For. I did it with Pow:  In the second exercise we had to show the number of stars that we ingress. Example: cin=5 R=*****  TC101

QUIZ   WSQ07 Sum of numbers

In this program we can sum the numbers between the ones you say.

For example, I you say the first number is 6 and the second 10, the sum will be 40.

So this is the code I wrote on XCode:  Also the code will be here in this link on GitHub. TC101

WSQ07  Quiz (C++) The past class we have a quiz. It wasn´t that hard, in fact for me it was very easy.

The quiz consisted of 3 programs.

The first program calculates the volume of a cylinder, you just have to ingress the radio and the height. Once you enter the data the program makes the calcule and tells you the volume. Then we have to make a program that calculates the product, integer and remainder of two numbers using int variables. It´s like the WSQ03.  The last program is almost the same but using float variables, adding the sume and  difference of the numbers, and taking away the remainder.  Once we finished the quiz we had to send it to our teacher.

Here is one of my friends post about this quiz.

TC101

QUIZ  WSQ06 Pick a number

Now, in this program, you will try to guess the number I´m thinking in.

First, I will assign a value to the number. Then you´re going to ingress a number and the program will tell you if the number is smaller or bigger than my number.

And here is the code: And here is when it runs: The link to the code on GitHub is:

https://github.com/Chema1807/TC101/blob/master/Pick%20a%20number TC101

WSQ06  WSQ05 Temperature Convertion

In this project I´m going to make a program that converts from Fahrenheit degrees to Celcius degrees.

The code is simple, but it has a little level of difficulty. Once I finished this is how it runs: Also the code will be on GitHub here:

https://github.com/Chema1807/TC101/blob/master/Temperature   