Learning Activity I.5
Purpose: Elaborate cyclic algorithms to solve different kind of problems. In this activity you will do the algorithm to give solution to problems where there is a condition toevaluate and bedsides, to repeat a series of steps that give solution to the problem. Here you will use the comparison operators and counter variables.
1. - Read the followingproblem:
Elaborate the algorithm that displays the sum of the numbers from the 1 to 10.
2.- In this problem it´s important to indicate that the algorithm will print the series of numbers from 1 to 10, thisis, it will display the numbers 1, 2, 3, 4, 5, 6, 7, 8, 9, 10. We know that the initial value is 1 and the final value of the series is 10 and the series goes from 1 in 1, this is, the increment is1. We will use a variable that is counting the increment. Let us elaborate the algorithm:
1. - Start
2. - Give to the variable N the value of 0 (zero)
3. - If N = 10 go to step 7 else go to step 44. - Increase in 1 the variable N with the formula: N = N + 1
5. - Print the value of N
6. - Go to step 3
7. - End
3. - Observe that continuously the steps from the 3 to 6 are repeated andthey will be repeating until the condition N = 10 is fulfilled. Now, in teams, elaborate the following algorithms:
a) Print the series of numbers from 1 to 10 and print, for each one of them itsrespective square. Note: The printing must be in the following form:
Cyclic Algorithms |
1.- Start2.- Choose any number from 1 to 10 3.- That number multiply it by itself4.- The number result must bethe square of the initial number 5. - Return to step three.6. - Continue makes the steps 1 to 5 until completes the number 1 to 10.7.- End |
9 8110 100
b) Print the series of numbers from 1 to 20 and for each printed number, print if that number is an even or odd number. Note: The printing must be in the following form:
Leer documento completo
Regístrate para leer el documento completo.