0% found this document useful (0 votes)
35 views6 pages

Solved Exercises Guide

The document is an exercise guide that provides algorithms for various programming tasks, including comparing values, summing integers, calculating the area and volume of a cylinder, converting numerical grades, and determining prime numbers. It also includes proposed exercises for further practice, such as generating Fibonacci series and processing sequences of numbers. Each exercise is structured with a clear start and end, and some include modifications for additional challenges.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
35 views6 pages

Solved Exercises Guide

The document is an exercise guide that provides algorithms for various programming tasks, including comparing values, summing integers, calculating the area and volume of a cylinder, converting numerical grades, and determining prime numbers. It also includes proposed exercises for further practice, such as generating Fibonacci series and processing sequences of numbers. Each exercise is structured with a clear start and end, and some include modifications for additional challenges.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

Exercise Guide

April 2010

I.- Solved Exercises

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)

IF A > B and A > C THEN


A IS THE GREATEST
WHO
IF (B>A and B>C) THEN
B IS THE GREATEST
WHO
C IS THE GREATEST
FIN IF
END IF

1
University of La Frontera - Programming and Computing
FIN

a) Modify the previous algorithm to display the smallest of the values.

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

a.Develop an algorithm that performs the summation of the integer multiples.


of 5, between 1 and 100, that is, 5 + 10 + 15 + ... + 100. The
The program should print the numbers in question and finally their sum.
b.Develop an algorithm that performs the summation of even integers.
understood between 1 and 100, that is, 2 + 4 + 6 +… + 100. The program
You should print the numbers in question and finally their sum.

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

a. Create an algorithm that allows you to determine the area of a rectangle

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

a.Implement the same algorithm using the Case statement

6.- Determine if a value is prime or not.

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

IF (counter <= 2) THEN


WRITE num 'is prime'
WHO
WRITE num 'is not prime'
END IF
FIN

4
University of La Frontera - Programming and Computing
5
University of La Frontera - Programming and Computing
II.- Proposed Exercises

1.- Read a number and show its multiplication table.

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

You might also like