Solved Exercises Guide
Solved Exercises Guide
April 2010
1.- Develop an algorithm that allows reading two different values, determining which one
the two values is the greater and write it.
START
A=0;
B=0;
DO
Read A
Read B
WHILE (A=B)
IF (A>B) THEN
A is greater than
who
B IS THE GREATEST
FIN IF
END
a.Modify the previous algorithm to show the smaller of the two values.
b.Create an algorithm that adds the two values.
2.- Develop an algorithm that allows reading three values and storing them in the variables.
A, B, and C respectively. The algorithm must print which one is the largest of the three.
values.
BEGINNING
A=0;
B=0;
C=0;
DOING {
READ A
READ B
READ C
WHILE (A=B AND B=C)
1
University of La Frontera - Programming and Computing
FIN
2
University of La Frontera - Programming and Computing
3.- Develop an algorithm that performs the summation of integers.
ranging from 1 to 10, that is, 1 + 2 + 3 + …. + 10.
START
SUM=0;
FOR (I=1; I<=10; I=I+1) DO
SUMA=SUMA + I
FINPARA
WRITE SUM
FIN
4.- Develop an algorithm that allows determining the area and volume of a cylinder.
given its radius (R) and height (H).
START
R=0;
H=0;
READ R
READ H
AREA = 2 x PI x R x H
VOL = PI x R2x H
WRITE AREA
WRITE VOL
FIN
3
University of La Frontera - Programming and Computing
5.- Develop an algorithm that allows converting numerical grades, according to the
next table:
19 and 20
assume that the grade is between 10 and 20.
START
Note = 0
NuevaNota
READ Note
IF Grade >= 19 OR Grade <= 20 THEN
A
WHO
IF Grade>=16 OR Grade<=18 THEN
B
WHO
IF Grade >= 13 OR Grade <= 15 THEN
C
WHO
IF Grade>=10 OR Grade<=12 THEN
D
WHO
IF Grade >= 1 OR Grade <= 9 THEN
E
FIN IF
FIN IF
FIN IF
FIN IF
FIN IF
WRITE NewNote
END
START
Read num
contador = 0
i=1
WHILE (i <= num) DO
IF (REMAINDER(num / i) == 0) THEN
counter = counter + 1
END IF
i=i+1
FINMIENTRAS
4
University of La Frontera - Programming and Computing
5
University of La Frontera - Programming and Computing
II.- Proposed Exercises
2.- Read a sequence of numbers and determine which one is the largest.
3.- Generate the first N terms of the Fibonacci series. The value N must be read.
by the keyboard. In this series, the first two numbers are 1, and the rest is obtained
adding the two previous ones: 1,1,2,3,5,8,13,21, …
4.- Read a sequence of numbers and show which of them is the greatest and the smallest.
the process will end when an odd number is entered.
5.- Read a sequence of numbers and sum only the even ones, showing the result of
process.
6.- Read a sequence of numbers and display the sum of the even numbers and the product of the odd ones.
what are multiples of 5.
7.- Read a sequence of numbers and determine the largest of the even numbers read.
6
University of La Frontera - Programming and Computing