0% found this document useful (0 votes)
605 views70 pages

PSEINT Exercises

The document outlines a structured programming problem set focused on pseudocode and its implementation using PSEINT, aimed at students in computer engineering and related fields. It includes a user guide, exercises on sequential and conditional control structures, and provides a format for students to document their pseudocode, desktop tests, and PSEINT encoding. Additionally, it references external tutorials for further learning and includes solved exercises for practical understanding.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
605 views70 pages

PSEINT Exercises

The document outlines a structured programming problem set focused on pseudocode and its implementation using PSEINT, aimed at students in computer engineering and related fields. It includes a user guide, exercises on sequential and conditional control structures, and provides a format for students to document their pseudocode, desktop tests, and PSEINT encoding. Additionally, it references external tutorials for further learning and includes solved exercises for practical understanding.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

PROBLEMARY

DESKTOP AND PSEINT TESTS

0INDEX

0INDEX 1
Solved Exercises 4
PRESENTATION 6
USER GUIDE 9
PART 1. Pseudocode: 10
Instruction block 11
Ends 11
PART 4. Instructions in PSEINT 11
PART 5. Execution in PSEINT 11
Pseudocode 12
Desktop Test 12
Encoding in PSEINT 12
SEQUENTIAL CONTROL STRUCTURE 13
Exercise 1. 13
CONDITIONAL CONTROL STRUCTURE 22
Exercise 10 22
ARRANGEMENTS and MODULES 44
9 SOLVED EXERCISES 60
L Annex I 70
PSEINT Instructions 70

Conditional Control Structure 21


Exercise 10……………………………………………………………………………...
0INDEX 1
Solved Exercises 4
PRESENTATION 6
USER GUIDE 9
PART 1. Pseudocode: 10
Instruction block 11
Ends 11
PART 4. Instructions in PSEINT 11
PART 5. Execution in PSEINT 11
Pseudocode 12
Desktop Test 12
Encoding in PSEINT 12
SEQUENTIAL CONTROL STRUCTURE 13
Exercise 1. 13
CONDITIONAL CONTROL STRUCTURE 22
Exercise 10 22
ARRANGEMENTS and MODULES 44
9 SOLVED EXERCISES 60
L Annex I 70
PSEINT Instructions 70
Solved Exercises

0INDEX 1
Solved Exercises 4
PRESENTATION 6
USER GUIDE 9
PART 1. Pseudocode: 10
Instruction block 11
Ends 11
PART 4. Instructions in PSEINT 11
PART 5. Execution in PSEINT 11
Pseudocode 12
Desktop Test 12
Encoding in PSEINT 12
SEQUENTIAL CONTROL STRUCTURE 13
Exercise 1. 13
CONDITIONAL CONTROL STRUCTURE 22
Exercise 10 22
ARRANGEMENTS and MODULES 44
9 SOLVED EXERCISES 60
L Annex I 70
PSEINT Instructions 70
• ANNEX I. PSEINT Instructions 68
PRESENTATION
The Structured Programming program is currently made up of 5 units of competence, within which the topic of Structured
Programming Methodology is addressed. Within this methodology, the definition of variables, algorithms, pseudocode design, design of
data flow diagrams and desktop tests for programming problems must be carried out. However, one activity that motivates students is
seeing their lines of code working.
There is a tool to assist a student in their first steps in programming. Using a simple and intuitive pseudolanguage in Spanish, very
similar to the pseudocode used in class, this tool allows students to visualize the result of their programming instructions; this problem
set is mainly focused on this point.
This series of exercises presents a series of already designed pseudocodes and aims for the student to perform the desktop test of
each of the problems, then code them in PSEINT and execute them. Pseudocode is the structured statement of the problem in Spanish,
which is a series of instructions more similar to programming languages, and desktop testing refers to checking that the instructions
stated in the pseudocode are correct.
The objective of this problem set is to develop in students the ability to understand the pseudocodes presented, analyze them and verify
them with desktop testing, then code them in PSEINT and corroborate results by executing the code.
This problem set is mainly aimed at students taking the Structured Programming learning unit (Learning Unit of the Bachelor's
Degree in Computer Engineering), however, it can also serve as support for students in other degrees (Civil, Mechanical, Computer,
Electronics and Sustainable Energy Systems Engineering) who take the Basic Programming learning unit.
It is worth mentioning that all theory is omitted because it is only a support tool. The theory is presented in the Structured
Programming textbook1.
To review the theory related to PSEINT, it is recommended to view the following tutorials (although they are not the only ones
that exist):
1. Tutorial on developing Pseudocode algorithms PSEINT #1 - Introduction. Available in
https://www.youtube.com/watch?v=aEMrTa-KIOE
2. How to use PSEINT and make an algorithm 2016. Available at: https://www.youtube.com/watch?v=dwFd4srugJs
3. PSEINT Tutorial Getting Started [The Basics] of Pseudocode. Available at: https://www.youtube.com/watch?v=MVLu5j5tgzA
4. Tutorial develop algorithms Pseudocode PSEINT #3 – While. Available in:
https://www.youtube.com/watch?v=KAZyKvUgRH0.
5. Tutorial on developing Pseudocode algorithms PSEINT #2 - Yes-Then ............................ Available in:
https://www.youtube.com/watch?v=2bETFtyc0Qw
In the last part, some solved exercises are presented, which serve as support to explain how to solve different cases that may
arise in each of the exercises. Due to the nature of the problem, a section on the solution to the problems is not attached. However, the
solved exercises can display a clear description to understand the use of this problem set.
At the end of the problem set, a bibliography is attached so that the student can, if required, consult some material to support him
in the interpretation and definition of variables.
The prior knowledge required for the use of this material is: Control structures, data structures, elementary primitive instructions,
one-dimensional arrays, two-dimensional arrays and modularity.
USER GUIDE
This user guide aims to guide the student in how to solve each of the problems presented in this compendium of problems by
describing the parts that make up each exercise and exemplifying a program.
The table that must be completed by the students is the following (see Figure 1):

Pseudocode Desktop Test Encoding in PSEINT

PART 2
PART 4
PART 1

Screen Execution in PSEINT

PART 3 PART 5

Figure 1. Troubleshooting format.


FORMAT DESCRIPTION

PART 1. Pseudocode:

This section presents a pseudocode program, a series of instructions that solve a problem. The instructions that may appear are (see
table 1):

Type of Instructions Instruction to use


Start and end of the program Start
Ends
Input instruction Read
Exit instruction Writes
Arithmetic operators +, -, *, /, mod (remainder calculation), div
(integer division), sqrt (square root), **
(power calculation)
Logical operators
I don't

Relational Operators <, >, <=, >=, =


Assignment ←
Concatenation +
Table 1. Elementary Instructions
And all pseudocode will have the following format (see figure 2):
Pseudocode
Start
Instruction
For better understanding, an exercise is presented below with block
explanations of what each section should contain.
Description of what the program should do
Ends
Design a program that calculates the square and cube ofFigure
a number.
2. Section for Pseudocode

Space to perform the


Proposed desktop test. The input value
pseudocode for coding in is proposed (checked) in all
PART 4. Instructions
PSEINT in PSEINT exercises. Pseudocode encoding in
and performing desktop PSEINT
testing
In this Pseudocode
section, the pseudocode instructions must appear “translated” into PSEINT instructions.
Desktop Test Encoding in (see ANNEX I)
PSEINT
N: 3 CUD algorithm
CD: 9
Write loves to calculate the square and C a number" number
PART 5. Execution in PSEINTCu: 27 Write
PART 2. Read n
cde-nAZ
A screenshot of the program execution and the results obtained from its execution should appear here.
cbe-nA3

Write square: ",cd, " cube: ",cb

EndAlgorithm

Desktop test screen Result of the execution


PART 4
of the program in
PSEINT

Screen Execution in PSEINT %

Program that calculates *** Execution Started. ***


the
square and cube of a
PART 1. number program that calculates the square and cube of a number Dome a number > 3
Give me a number square: 9 cube: 27
*** Execution Completed. ***
3 PART 3.
Square: 9 Cube 27 PART 5
TO
SERIES OF EXERCISES

SEQUENTIAL CONTROL STRUCTURE

Perform the corresponding desktop and screen tests, code in C and run the programs so that you can complete the following boxes using
screenshots.

Exercise 1.

Write a program that calculates the perimeter and area of a circle given its radius.
Pseudocode Desktop Test Encoding in PSEINT
A: 4
Q:
ex., "be (" Vwoe-o qe TO:

5 *• be ( D e,.e et ig

Pi 4— E. Z. 3.1416 Screen Execution in PSEINT


$ PX x 2.x 3 116
Esev,be ("Pbiet.. ", either,
"Atheist" (Á)
Ta i minn
Exercise
2.
Write a program that calculates the quotient and remainder given two integers.
Pseudocode Desktop Test Encoding in PSEINT
N1:
8
AND,___________- ■ j N2:
3
ket
E-re ( " Domc e I didevo ' ) ।
L,e ME
D4— Nt dN, qe— Na mo N.
esesive("Eoziente.o, f j <4 _

Screen Execution in PSEINT

1
3
Exercise
2.
Write a program that calculates the area and perimeter of a pentagon.
Pseudocode Desktop Test Encoding in PSEINT
L: 5 a: 4 PM:
TO:

reader,

"C"oace it all")
P.
M- -("Da- Io apolc")
Screen Execution in PSEINT
"! A e2 / A '
Iq

1
4
Exercise
2.
Write a program that performs the sum of two integers
Pseudocode Desktop Test Encoding in PSEINT
n1:45
n2:67
A:
-be (" P -ouv- e- sum E
CM. be C*' PlUM.LT {,ney________1

ter

T.
— Screen Execution in PSEINT

1
5
Exercise
2.
Write a program to calculate the square of 243
Pseudocode Desktop Test Encoding in PSEINT
A:

< g {8 ? 9 T = f- ~ 2 2Lvi 2 }x , { J HH A 2 2
1 or N - -

Screen Execution in PSEINT

1
6
Exercise
2.
Write a program that calculates the perimeter and area of a rectangle
Pseudocode Desktop Test Encoding in PSEINT
b:6 h:3 P: A:

ce-rno • Ar- a- o"

fetv pe5 - esuie e "Dame • otu.") leev W


Pe— 2-th
A 4-------- b * W
is«be ('Pevicet.o" P,
"Avemt •» ' Screen Execution in PSEINT
. ‘°2

1
7
Exercise
2.
Write a program that reads the make and model of a car from the keyboard and prints the model and make on the screen (in the reverse order of
what is read)

Pseudocode Desktop Test Encoding in PSEINT


MA: “Jetta” Mod: 2017
start

g outo~ouilts")
leev MA --e
Beibe ("Dowe the model of ~-0 lecv
Mod
1 ecvbe ("Model: " Mce
" Mov of | \
Tevmiw, 0toi7mA) Screen Execution in PSEINT

1
8
Exercise
2.
Write a program that calculates the hypotenuse of a right triangle.
Pseudocode Desktop Test Encoding in PSEINT
c1: 4 c2: 3 h:
Home
exvbe ("P..cawo caxa cakdlav
the wipotew.s A- aw tiovgol
let tov9slo ")

h4— sot (<,-6.)


Csibe ("hipotvgg" L Screen Execution in PSEINT
1 In/
Tetwun

1
9
Exercise
2.
Write a program that calculates the percentage of an amount.
Pseudocode Desktop Test Encoding in PSEINT

Screen Execution in PSEINT

2
0
CONDITIONAL CONTROL STRUCTURE

Exercise 10

Write a program that indicates which is the largest of four integers.


Pseudocode Desktop Test Encoding in PSEINT
a: 26
b: 78
Cx-e('Rag,a. polo Adi et
c: 21
d: 43
"e -,-,1,4

ctet ( " Movo, .Ve)


' d 29 yd>k 4 d >e e-temLe.
cCSj5'""*yod" ,4)
Screen Execution in PSEINT

2
1
Exercise
2.

Write a program that indicates if a number is divisible by 14


Pseudocode Desktop Test Encoding in PSEINT
1st. Test: num: 84

Test 2: num: 80

-•—

r./ Screen Execution in PSEINT


I HEARD

2
2
Exercise
2.

Write a program that indicates if a number is a multiple of 6


Pseudocode Desktop Test Encoding in PSEINT
1st. Test: n: 25

2nd. Test: n: 48
let. . 5 1"

Screen Execution in PSEINT

2
3
Exercise
2.

Write a program that indicates neither a number is even or odd.


Pseudocode Encoding in PSEINT
Desktop Test
1st. Test: x: 25
Phecdoceig- _____
2nd. Test: x: 48
and ( rac9 . or qg (ao s; J. +ee. -u esoviWe (e Ocw
on wwet )
1 eev X
$c(kwws 3-e) enkees
ex iVt Cx , is pav ' ) cho
Eslvike ( xr is iweo ) hw 56
leoma
Screen Execution in PSEINT

2
4
Exercise
2.
Write a program that indicates whether the sum of two values is positive, negative, or zero.
Pseudocode Desktop Test Encoding in PSEINT
1st. Proof:
a: 25
b: 78
S:

2nd. Proof:
a: 48
f 3e v,V, ( i ftev Q, b b: -56
S 4—0+ L S:
s, (S>o) eutomtes, ,
t,enke ("sa-" 5 p
Sics <03 mto-' „C- Screen Execution in PSEINT
rbt("fowu- ",5, Ne Viw)
p

eciq

2
5
Exercise
2.
Write a program that indicates whether a number is divisible by two and five (at a time).
Pseudocode Desktop Test Encoding in PSEINT

m—sga 1st. Test: n: 25

e-,b- (" p.ograwe q au,, 2nd. Proof:


•v -w vvatNo F ”
n: 480

If(n voa s = o - w -od 1 - O) = wtne* •


es.re ( n, "e, ai-sow rwte2 -s»)
,,cue ( w,"wa e.-;g261, .ww
Fiw ,, os) Screen Execution in PSEINT
(+lwiwa

2
6
Exercise
2.
Write a program that indicates whether a person is overweight (if it is considered that they should weigh the number of centimeters they measure
minus 100 or less). The data must be positive.

Pseudocode Desktop Test Encoding in PSEINT


1st. Test: e: 165 p: 50

2nd. Test: e: 180 p: 85

Screen Execution in PSEINT

2
7
Exercise
2.
Write a program that calculates the change that should be given to a customer
Pseudocode Desktop Test Encoding in PSEINT
1st. Proof:
D:100
I/wo C:28
Co-bi at demnte " M:

1 tou,"("Ono-t-godep- 2nd. Proof:


lerv v "52 D:100
C:108
S", bt (* Cosho dt\ evscto3" 'te C M:

5(03=cent, 4 Screen Execution in PSEINT


F±—cD
Eiw,esuucoe Cifotta: e, F )
Lej 9,
15%-M

2
8
Exercise
2.
Write a program that indicates whether a number is divisible by 14
Pseudocode Desktop Test Encoding in PSEINT
1st. Test: num: 84

E3ube ( bina Test 2:


number: 80
err A •) 'scvr (ADaw.
(n**o") lrc M
S ( W vo d IA FO ) twto-e?
esxibe (w,"4,dii'vk' Oo
Esxbt (w, 'wo ts fh* )
• iys;
F,o yes Screen Execution in PSEINT
levmino

2
9
Exercise
2.
Write a program that indicates whether a number is a multiple of 6.
Pseudocode Desktop Test Encoding in PSEINT
1st. Test: n: 25

2nd. Test: n: 48
eg, or ( wp,0n/owa qle de levwo
s J. womeo and "eottelo and J leev
v
S: (wua c -o) ele*
• esvic (n,"t wlteb'') otv ° , esv;be (w,"wo
t--Welol, f:as

Screen Execution in PSEINT


1 Rv• •N

3
0
Exercise
2.
Write a program that displays the day of the week given a day number
Pseudocode Desktop Test Encoding in PSEINT
1st. Test: ang: 25
Imito.de cowegou ponve dele-mivov
2nd. Test: ang: 148

Esc. be Dave ow avqu o”) 3rd. Test ang:90

LSCovbe C"AnQUIO Qqodo'r Si(ang

290)elohces
Screen Execution in PSEINT

Tev •¡ c,

3
1
Exercise
2.
Write a program that displays the day of the week given a day number
Pseudocode Desktop Test Encoding in PSEINT
1st. Test: x: 25
YO,.
("!•< .u (-dito A Sf i—see e.vue ( "Done • dca") - P{ e A , 2nd. Test: x: 4
_________________________________________\

Nt.o, * ¡
v-1 Tameel
eu-ws tLoo" ' I1
x:3 / \
ew ("Miuv vt5") L\
x- 4 and esvibe ("Neule") Screen Execution in PSEINT
,. s -
AND
ec;b, "Or"e F
L .1 ¿ 4
euowe ("Ncomes")
x-1 , (
$beuhe(obode J
EITHER____________________
escube (" Ewe v) Rvuew of 1
f.aus Xc1
-r- 55
"ITEM
YO
\

3
2
Exercise
2.
Write a program that performs addition, subtraction, multiplication, division and exponentiation of two numbers using a menu

Pseudocode Desktop Test Encoding in PSEINT


1st. Proof:
o: 2
a: 98 b: -45
r:

2nd. Proof:
•..w (iRudwe q vtaku ogeu oe o' ewo
o: 4
U¿
1. U, h* - muttipctc 4 0L A.Am*
' 1 a: 98 b:-4
(either)
0- 1 r:
5 (0 -6--)
. t-—.a, p, s,0,o
(v-t0)
exW (*Ge wc,-ebde' iev
And r*^ a-b
P-he Cte ",5)
•.we ('NUlau")
.wLcDouee wuVeinoode - --tpuiot ')
■ -— Oib
eve ("Hdheoli ",v)
d- 4
g-..20rC'Di-ucu) v
neo-- God“)
. 2: TO
co
' +— A/b . ,c bc.be ("ia D--aar", Q, "ekc", be') k- »

0’ 5
t*vt (* Vcteiuccw" ,
cowe (Don Vue 9 Rimi'
lres av
c4— QAb ,
es-vibe ( "a, "elevated qlu", . üoltwei <>5 " And
okay
exc.,k [" ee« in occu ) hw do
-

3
3
Exercise
2.
Write a program that calculates the area of a square, a rectangle and a triangle.
Pseudocode Desktop Test Encoding in PSEINT
1st. Proof:
esqbe ("Rroorwa o coko uveoi de Beus) o: 2
eo,oe (" Me o, -xe.: 4 c+ dodo Afet x: 8
3 T. , to.. " ) and:-5
is-ve ('Owe een") TO:
Ie Oft,
co- cege> 2nd. Proof:
Of 1 o: 3
this (Coakobe') ab::-94
esxbe 1 "Dowe yedhida de 0e LD
TO:
leev X

ewNecAq:'A) Screen Execution in PSEINT

ev,be ("Oowe •*didns des wees'


lecv X,u
A — xL9 1_
e»-Vc (epve'fA)
1

eswDe (" Vovoulo[


eEvive C" Dome bosr 9 olliu )
____ lewv,-
«i — A +- (x *9)/2 ___
...................... Digging) ___________________________
_ Oh
eube C“Godel Rogava”)
ncos

3
4
Exercise REPETITIVE CONTROL STRUCTURE
2.

Write a program that calculates the largest, smallest, and average of N numbers.
Pseudocode Desktop Test Encoding in PSEINT
N: 10
x: 5,8,6,2,0,4,2,-6,1,
7
p:
g:
m

Screen Execution in PSEINT

9--*

3
5
Exercise
2.
Write a program that indicates the number of digits that a quantity has to the left of the decimal point.
Pseudocode Encoding in PSEINT
Desktop Test

or: 275932.89
Ieki0 (ePr-erama o—-note —0iP " w -5 •' —— I ,1 c:

Screen Execution in PSEINT

3
6
Exercise
2.
Write a program that adds the series 3,6,9 up to 99 and displays its result.
Pseudocode Desktop Test Encoding in PSEINT
p
- g K 3 P p3 PH í 0

YO:
TO:
A > 9 owg 3 f 3 Htve9
¥°" A i, gV(LP
- § tHH w,§

FEITHERand0

Screen Execution in PSEINT


25 —P•AA6’

i • —R _
" either8
<7.121 /m
5:..N5'II(

g— $
_1 1 O —
1D g
18

3
7
Exercise
2.
Write a program that prints the odd numbers from 7 to 51
Pseudocode Desktop Test Encoding in PSEINT
YO:
Jycio
eavbt ( 'Pvegvaw (opo;we imPves
devtavs)
147 •
Wientvos(L¿-sL)
Escvibe (1)

kn Less lo/mine
Screen Execution in PSEINT

3
8
Exercise
2.

Write a program that verifies if a data entered by keyboard corresponds to the password 252525
Pseudocode Desktop Test Encoding in PSEINT
1st. Proof:
I Pseudédio.
x: 2525, 252525

Hu 51

Screen Execution in PSEINT

3
9
Exercise
2.
Write a program that indicates positives and negatives of a set of 25 data (use control structure for).
Pseudocode Desktop Test Encoding in PSEINT
Perform the test with
escutve vp.q.. qae ts nmevs die co10 10 data.
Posc f« 0o5 and ge-o ho» "
x: 2, -1, -3, -8.-7, 2, 4, -
h-—o
5, 7,8
Vovo > O vosta zs ( < nc ) cusike
"Dome on mgw-) (eec p:
s, c x-0-.te, n:
'n yes
S cx>o)e -pve
v.'dP
Í i egg
EScbe ("Pos:VuosI,
"Napluucg*,) lesmcu . Screen Execution in PSEINT

4
0
Exercise
2.

Write a program that prints on the screen the integers from 1 to 30 with their reciprocals.
Pseudocode Encoding in PSEINT
Desktop Test
o A L, 9DP

° 8•gc ~ 9Rd

8„,% 0-L
< Co I * -D Hs2

eitherg
-F ••Q.
eqtoA $ A

0P 2?4
803'
5 C6 g -

~ {% G
-Sh0
—6
4-
3_ Yo

Screen Execution in PSEINT

4
1
Exercise
2.

Write a program that indicates the number of positive and negative numbers in a set of 25 numbers.

Pseudocode Desktop Test Encoding in PSEINT


Perform test with 10
Start values:
esvibe ("Pegvavva ov gives you the
Sow ce 25 nGwecs")
x: 8,6,12,3,1,64,9,33,4,11
SW S:
Pov 1=A host 25 Zinc) cscvbe ('Dawe
húwec") Go*

$< 5+Xx
Screen Execution in PSEINT
Fiw turkey.__1____|
j pulí k»¡ L the suMu is: ", d)
[ev vi

4
2
Exercise ARRANGEMENTS and MODULES
2.

Write a program that indicates to store 100 data in a one-dimensional array and indicates how many positive elements there are in it.
Pseudocode Desktop Test Encoding in PSEINT
Perform desktop test
0.
with 10 data
exvdt (Ykeonoq die t oc. the peacock of the flock"
eS- N. fl 2, a: {5,8,6,2,0,4,2,-6,1,
"IveDeqe •owawo ~* Ste 3 ke k" ec h 7}
p:
5, n> » ne = We ekco
P... =4+ rubber n evw)
• the bt C * Dune owuc") tery aci >
. 5, (oi)> €-v- ps'
T(wove

e-vo ("Elem posFeg: p)


ON® _
estvcot ( Evece ) Screen Execution in PSEINT
fi -i
wash~u vw

4
3
Exercise
2.

Write a program that indicates which is the largest and smallest element in a vector of N positions
Pseudocode Desktop Test Encoding in PSEINT
—3 Perform desktop test
— #tbt-( Follow that 4 .>3 the +tewArwfo with 10 data
N=10
icev A A: {5,8,6,2,0,4,2,-6,1, 7}
Ma:
czfr1 hos+. TO Me:
Receive'0qmeol v.wa, \
YO:

—1 Aw 5 7*
•. 232
1 ____ (AtI < meNamtw.a,
Mt -- 4c1] Screen Execution in PSEINT
11j।
| I Cxvbe ('Mayov . • vo, ' Mecen we N

4
4
Exercise
2.
Write a program that fills a vector with 0 in even positions and 1 in odd positions.
Pseudocode Desktop Test Encoding in PSEINT
l.no . Perform desktop test
esbe [ And,vawa Uena i Gak q. " ev > with 10 data
sostges ove oc lo > iwat, ") to:
I-vo iL Wos cm) {__,__,__, __ ,__,__,__,__,
51 i mod 2 o ewtce eCi|—-o __ }
h* :
5i mod 2
I heard]--
fen
Fo pcva
exvbi ("New Nelov")
fovu (-l Vo stu H coL goo 1 write ~C,
& to either• -________ Screen Execution in PSEINT
back

4
5
Exercise 35

Write a program that searches for a number in a vector of 10 positions and indicates its position.

Pseudocode Desktop Test Encoding in PSEINT


Iweo Perform desktop test
eunbe ('Rgoug that makes onxe-enonsel)
Poo i --1 mr w (me) with 10 data
exx,hx "" Vyrse ci", i, "Mumtva ")
Lrn Li)
fh Pow Vector: {5,8,6,2,0,4,2,-
that be ("lyese the name • searched ' 6,1, 7} number: 0
ecv wUveo
position:
Podo- —or

ro ~ - vust. Ag cind)
I 5, (ves m Ci J e vauiyewe e*- -1-
IVF 2,
Fo Pov
S (romun<>epeninces Screen Execution in PSEINT
e..,be ("M-uu. Ue- vuwae ,(F et") tko .
ex v; te (r Noew ve euo w ktodo •)
, fon >.
hsm)o-

4
6
Exercise
2.
Write a program that saves the sales of 10 cashiers for 180 days and indicates which cashier sold the most, the day with the most sales, and
the total sales.

Pseudocode Encoding in PSEINT


Desktop Test
Perform desktop
test with: A:
{50,80,66}
{29,40,47}
{22,69,91}}
h:
k:
ma:

Screen Execution in PSEINT

4
7
Exercise
2.
Write a program that records the blood pressure of 30 people for three days and indicates the day that the person had the highest blood pressure
and the lowest blood pressure.

Funou1
. Ra ; 1 host 3 i M)
Pseudocode

Put jea vostaL 30 J_L


ft!. । j pf hfF
Desktop Test
Perform desktop test
with:
Encoding in PSEINT

eso.h d-Dame tletko del da,;,4Delwa, ;) i. 1 ldeyALi,jl ' 5 A: {111,80,66}


(-is) .
=$c6 jd _ — {99,84,147}
{122,89,91}}
' 26th..........Qe.tu h:
"—4ci- k:
ma:
me:

•• pu Screen Execution in PSEINT


ne=-Acj . . , ip
-Yo,. ...............
c. --3
4fi. —
e X "Di mt qeh va precon' 4 on elms " x
That is? com WM> ptU- 11 a MtJ-" h)
Thmya — ' ' 1 •

4
8
Exercise
2.

Write a program that captures a 10 X 10 matrix with integers and at the end of each row prints the sum of its elements
Pseudocode Encoding in PSEINT
Desktop Test
Enkoddkye Perform desktop
test with:
• ' ' Nee uro cast d 10x10 at fhal c . (ociq yelqle ■ A: {50,80,66}
"hevbg • awaq, {29,40,47}
yes re1 kesi . 10 cio 1 {22,69,91}}
:
Poss pl w ' • I n J
lexcibe LDawr <3u * J 1 I ¡ 1 .1 |ij s:
. It4u , A Ci]s3 1 1 J 1 1 1 1- j
. End . fa*

Screen Execution in PSEINT


2'

o- j - 1 hezl dO ( ut) • 1 ! j | 1

t ■ "5 b HFA)
iv eu'W .
—iimm--Hey

4
9
Exercise
2.
Write a program that captures the production of 2 plants for seven days. Indicate which plant produced the most and on what day.
Pseudocode Encoding in PSEINT
Desktop Test
Perform desktop test
esxke (Rogv a qu dce oce pl4e pvodue .Ga) with:
A: {50,80,66}
{29,40,47}
. fbvo J =1 hosto I2- Cinema )_
Pova- A Vosiq H(iw) 1 1 I 1 II {22,69,91}}
%, ( and 3 Jonlonce» s:
esdvbe (I Uorac pvodeceic del d( - ; “de (o ponN X ")
Leev AC,j2
0—04 AC3
b:
eugder, • asen dildoer, vae lepiofa 1 to:
UMAE ' b = b 4 AQiJ fin $ _ ,1i
Screen Execution in PSEINT
. end Qovq || r. 1
1
5,, 1 PT”
‘ "2 --
Evbe L « pinevebhh tu toyou Podecion".
S,E6) eonte, ~ 1 1 II 1 1 1 a ccobe ( a 4^ way
fi.q
Tévive— - | J ■
1 4
s

5
0
Exercise
2.
Write a program that places data on the main diagonal of a 3 X 3 matrix.
Pseudocode Encoding in PSEINT
Desktop Test

-i' [o Perform desktop test


A NA with:
m"be 1 Mogawe qve (eoto datseu le voqou\ pviicui c uvawak',1) TO: {___,___,___}
v.t ' {___,___,___}
Go lc 1 hos 3 Ciwc) eeube ("Dawe cc+" ) leev Aci,i) {___,___,___}}

Frw Pov

People i = 1 to 3 Cinema)
€scvi be AVi,1)
1 C Pdio
7[ ev u- MD* Screen Execution in PSEINT

5
1
Exercise
2.
Write a program that indicates the largest and smallest elements in a 10-position array.
Pseudocode Encoding in PSEINT
Desktop Test

Perform desktop test


1 —Ez with 10 data
A: {5,8,6,2,0,4,2,
6,1, 7}
ma:
me:
h:
k:
YO:
rGil ; ——
fnP . u,ge » ,g wc) Screen Execution in PSEINT
euwtr(Moyov :",mu,'6u kion:, n, Dwe ,te, Yoo",E)
- ■ ' 1

5
2
Exercise
2.

Write a program that reads a vector A of elements. You must create two new vectors B and C, such that vector B contains all the odd numbers and
vector C contains all the multiples of 3. At the end you should print all three vectors.

Pseudocode Desktop Test Encoding in PSEINT


Perform desktop test with 10 data
V: {5,8,6,2,0,4,2,-6,1, 7}
B:{__,__,__,__,__,__,__,__,__,__}
Inicoescnocc p,ojvama that ice unuedor ewata ivxves
A:{__,__,__,__,__,__,__,__,__,__}
(N multiples of 300)
Para 11 Hástd 10 (ink) write(toome doto' ) teet vLL1 -
End Duck
i41 k:
3—1
K<1
51cvülmom)=1) then A 1 jl =NLL} Screen Execution in PSEINT
ngjt /
51 (Ml Í1 mod 340) chtoy«és
BUftli] X
K=kt1
Finsí
Up to (10
Paia Wasta Kl 1

eSale LALK1
End of strike
Paia i=1 Mosto KUiKi eschibe (rrnuinpues de 2') esaie (BLK1
Vin pdr 0

5
3
Exercise
2.
Write a program that searches for a number in a vector, indicating the position in which it appears and the number of times it is repeated.
Pseudocode Desktop Test Encoding in PSEINT
Indoesccuccrpcyamu aue search i nümco in an Perform desktop test
inavox posion N >eces~uc se eMi
41—
Kettle 1'1 HosO 10KIK).
with 10 data
esrioe ("'Dre doVo । • e icet v[) V: {5,8,6,2,0,4,2,-6,1, 7}
eenve l -Foatos aavtuvados'")
x:
Sexeum yours. --
Finmicoias edi0u,
cctibc EIDame ciato HM- D-2 i
z:
ice a
Pass 1-1 Hoso 1o(nc)
if (xN,) cn1onet3
scnk ke anose yonoen la vo-cón". •)
Tin cream , ,,
csooe CSc ievie ««S'

Screen Execution in PSEINT

5
4
Exercise
2.
Write a program that reads a vector A of 10 elements that determines and prints which is the largest and in what position it is located and which is
the smallest and in what position it is located.

Pseudocode Desktop Test Encoding in PSEINT


Perform desktop test
7+ 2 with 10 data
TatLLcD.-e 0s0+0s) A: {5,8,6,2,0,4,2,-6,1, 7}
Read Aci3 ma:
me- AC J
P,41 me:
Repte h:
k:
YO:
,4 i

5» (ACiD¿me ) • Screen Execution in PSEINT

ts he ( Ve2l0, 1

E.be(N01,1"
14 < {
Has+o qeCi 210)
Esc- 'be (Maqor, ma "Posc6-, i)

5
5
Exercise
2.
Write a program that fills a 10 X 10 matrix with integers, passes the elements to a vector, sorts them, and finally returns them sorted to the matrix.

Pseudocode Desktop Test Encoding in PSEINT


(• dote * em "edn**
Perform desktop test with:
7 And we--“ "ep'0o

PeuenEt verse 10 Cinema)

!<** ií-sp
VCw37 x Ci,3}
1
1 fA little X: {50,80,66} {29,40,47}
1
1 ke3 {22,69,91}}
1
ieplle ,
' WLK}>VEL-)endonee:
Yo 1 ' aK-VLM
¿ 1 I VEkJ=VCL

-Swa •
! NLL-QK V:{__,__,__,__,__,__,__,__,__}
wastotK5 B: {___,___,___}
K*ls}a) p3-,,. {___,___,___}
,' 1 00.3-=VUK
S -2* hobeG210) {___,___,___}}
iai iotaigc, ¡ 32-"
aux:
. v. canecv,,3 ,) _"K—_________________
Screen Execution in PSEINT

5
6
Exercise
2.
Write a modular program that uses a menu to calculate the area of a triangle, rectangle and circle.
Pseudocode Desktop Test Encoding in PSEINT
From the /OT akle>
beginning of ~oBo cucdo
op: 3
10ci() 1 (ft egdulum icdlorgud
r CR
MoBo cork tri()
b:5
"k.-pao A:4
p. cce ()

Rdshe- 5: (• '0) Hey Are:


poo
1* boh *gecko ° "e
or' RIc)
Coco (op) —i °a
,- AQ —q
Fan *•either “Sce:"Tegecbe kaboc
E"kc: 5m,LcaAA Screen Execution in PSEINT
"S" Regco today
Esmvke
:" 2. . 25400
V Inc'o,
ae TO "
(opz4)
Keim.ee, pe *. -I know v
titeaFoseo k»oWv«o

5
7
Exercise
2.
Write a modular program that simulates an ATM with the options of deposits, withdrawals and viewing balance.
Pseudocode Desktop Test Encoding in PSEINT
R muigel c 7 opt:2 r:
otc,f U 2
*' Poe—--uC) p:
opescs.c)
rac) radius() rad:3
ofe 2...c I
e- p- c )
oe5m.2c )
°fheee)
fa, "Hail."
oe-Z „ .
Ac (, "P-um * 1
. c-.
S.- ....

T--- Screen Execution in PSEINT


L. , (x , ch£20 ch-, >
L,u .
ascle ( ch//
Tm- ___________________
— , \ R o./, ()
And ford" •nae
EEw-is.a IT 1 oe+ E
Aapile ,
ler< rod ° '°
h.gL.cv170) reg-"9 e
reg-- 'ae \ T-mm

T.-. 1

5
8
Exercise
2.
9 SOLVED EXERCISES

Write a program that calculates the square and cube of a number


Pseudocode Encoding in PSEINT
Desktop Test

1 10 n:3 cd:9 CUD algorithm

€5cv i and (Roqvowon that caltola cu:27 Write "program that calculates the square and a bucket of a nuñero"
Write "Give me a number"
Faith 1 Read n

( Dowe or wGmnesc") cd<-n*¿


cb<-nA3
leev
CD --------- R Write "square: ",cd, " cube: ",cb

Co, -------TO, 3 EndAlgorithm

ÉSth bc ( “uavol” ca
t,, t 1 1
Screen Execution in PSEINT

Cubot ') "Program


lev~i M which calculates *** Execution Started.
the square and program that calculates the square and cube
cube of a of a number
number" Dome a number > 3
3
Square: 9 square: 9 cube: 27
Cube 27 *** Execution Completed. •••

5
9
Exercise 49

Write a program that

Pseudocode Desktop Test Encoding in PSEINT


' Iuiuo )> fi x:4 z:5 s: 9
=»ebt ( P oovov-• goQ >ovvex t
hOmc-os eil.o> 1
Sebe C''Pome +onr "and
Sun algorithm
read • n 1
E*wv ( nDow t Z° -pee 1
Write "program that adds Z numbers"
three, Write me the first number"
1 Read x
*—"1+n Write the second number
csoibr("Read,R") Read zs<-x+z Write the sum is equal to:" ,s
EndAlgorithm
le-ino, /

Screen Execution in PSEINT


Program to add two
integers Give me first *•* Execution Started. **• program that adds 2 numbers, the first
number 4 number > 4, the second number > 5, the sum is equal to: 9
Give me second number Execution Completed. •••
5
The sum is ugia to :9

6
0
Exercise
2.
Write a program that indicates how many numbers there are to the left of a quantity.

Pseudocode Encoding in PSEINT


Desktop Test
Pseudoco I say.
1-co (rp, ..0a qce ' wat ta digito • lo ito. debn nine
x:453435 c:6
tlev,ue (“Dow” data”)
_Ieeyx— L——————_ DIGIZ algorithm
Cec Write "Program that indicates digits to the left of a number" Write "Dane data" read
Deike xc <-0
k4xDIV10_ Repeat
C—c+1 1 x«-x/10
m (x-1) , Yo ce-c+1
cscv,e C er Dio: os 1 q lu ■ Y# Y- ___ __________ . Until x<1
Write "digits to the left: ",c

EndAlgorithm

Screen Execution in PSEINT


Program that
indicates how
many digits there
are to the left of a •** Execution Started. ***
quantity Program that indicates digits to the left of a number Dome data > 453435 digits to the
left: 6 *** Execution Completed.
Give me
information
453435
Digits to the left: 6

6
1
Exercise
2.
Write a program that indicates whether a number is a multiple of 6.

Pseudocode Desktop Test Encoding in PSEINT


Fg N: 6
MY algorithm
.n grpp" Write a program that tells if a number is a multiple of 6"
"cu 1 f- " ■ ""ht ! Write GIVE ME A NUMBER"
Read N
51
(n woó G<7°)ente If N MOD 6 -0 THEN
Write N, “IS A MULTIPLE OF 6'
FinSi
End - ' If NUM mod 6o0 Then
| Write N, 'IS NOT A MULTIPLE OF 6"
ltvminu FinSi
Final Algorithm

Screen Execution in PSEINT


Program that tells if a
number is a multiple of *•* Execution Started. **•
6 Give me a number 6 PROGRAM THAT SAYS IF A NUMBER IS A MULTIPLE OF 6 GIVE ME A
6 is a multiple of 6 NUMBER > 6
6 IS A MULTIPLE OF 6 Execution Completed.

6
2
Exercise
2.
Write a program that indicates the largest element and its position and the smallest element and its position in a vector of 10 positions.

Pseudocode Encoding in PSEINT


Desktop Test
Perform
desktop test
with 10 data
Ei A f -2 1 2, s 425
Yo: -J<?* * -1' 21Fa í
652-9 p—n \n TH . , - $

A: {4,7,9,6}
ge

i:1,2,3,4 m:4,7,9
me:4 h:1,2,3 k:1
and , 2H-

Mamen algorithm Dimension 0(100)

Write "Program that tells which is the largest and smallest element of a vector and in which position it is located*
Xi

Stop ic-1 Up to 10 With Bottom 1 Do Write “Dome data” Read o(l) if i-1 then ma<-a(i) me<-o(i) hi k-í EndIf If a(i)ma Then 1 mo<-o(i) 1 h- EndIf If a(i)eme Then i
meqoCV
M

EndIf End To Write Major. ,ma, Position ",h,“ Minor ,me. Cake,k 1
toAND

EndAlgorithm
2
r

Screen Execution in PSEINT


8 HH

Program that tells


••• Execution Started. •••
what is the largest
Program that tells which is the largest and smallest element of a vector and in which position it is
and smallest element
located Dome data > 4 Dome data > 7 Dome data > 9 Dome data > 6
of a vector and in
\8H

Major: 9Position: 3 Minor: 4 Position: 1


what position it is
located
Give me information
5

4
Give me information
7
Give me information
••

9
Give me information
6
Major: 9 position 3
1

Minor: 4 position: 1

6
3
Exercise
2.
Write a program that uses a vector of 100 elements and indicates how many of them are positive.

Pseudocode Desktop Test Encoding in PSEINT


1

exwe ( Regyoweqg die c oso elem pceitrus du e\ usup.o"


n:3 a:{4,5,6} p:3
®nbt (What is it about? that is, it is ~06R' lec
h Elpos algorithm
Dimension 0(100)

5 n> - w< = W ew.co write "program that tells how many positive elements the user gives" write 'What size do you want your vector to be?' read n

P... , = 4 wwluN erwe) If n0 and nc-100 then


Stop i-1 to n with step 1 write Dome a number" Read o(i)
• e»ubtc" Duwe uw wuo • teev a CO
i 5 (oi)>k €w'wvt+ If a(i)>0 Then
1 pA-p.1
FinSi
( -P1* EndFor
Write "positive elements, p

Tsc-gi 0022, But


| Write "Error"

°be Q (, (" c ,iy FinSi

e>VDC I —vov /
fm -i EndAlgorithm

Tavmlivw

Screen Execution in PSEINT


Program that tells how *** Execution Initiate. *** program that tells how many positive elements the user gives.
What size do you want your vector to be? > 3 Dome a number > 4 Dome a number > 5
many positive elements Dome a number > 6 positive elements:3
the user gives, what size *** Execution Completed. **•
do you want your vector
to be?
3
Give me number
4
Give me number 5 Give
me number 6
Positive elements: 3

6
4
Exercise
2.
Write a program that places satos on the main diagonal of a 3X3 matrix

Pseudocode Encoding in PSEINT


Desktop Test

m,so Perform desktop


et"be í Pogamg que ceota dateseu la test with: MATI algorithm
Dimension 0(3,3)
-9®o\ pikiul c Uvawak'z") Write "Program that places data on the main diagonal of a matrix"
X: {2,__,__} For i=1 to 3 with step 1
| Write this information"
1 Gto Í = 1 host 5 c} {__,3,__} | Read a(i,i)
EndFor

eseibe ("Oowe do4c") {__,__,4}} For i-1 Up to 3 with step 1


I Write o(i,i)
[Leev Ati,i] i:1,2,3 EndFor
EndAlgorithm

frw Pov
People i= J hosa 3( ine)
Screen Execution in PSEINT
esevi be ACi,i)
Fce P d. Program that
TevevD places data on
the main diagonal
of a matrix
Give me
information *•* Execution Started. **•
2 Program that places data on the main diagonal of a matrix dome data > 2 dome data > 3
dome data > 4 2 3 4
Give me *•* Execution Completed.
information
3
Give me
information
4

6
5
Exercise
2.
Write a program that uses a 3 X 3 matrix and indicates the sum of the elements per row

Pseudocode Desktop Test Encoding in PSEINT


Euo ■
edibt (Pregana Le Ve un, Wvrt. d 10x10 to end, 1 ,
Perform desktop test Math algorithm
Dimension 0(10,10)
1 1 1 1 ¡ with: Write "Program that writes the sum at the end of each line"
4---- - VSGloM ScVc S 3U_ For i=1 to 10 with step 1
41Parq=1 host 10 (ic)_
(z Poq e1 vablo 10 Zinc) 1
- - ------- -exvibc (lQawrldat'? J )
1 || X: {1,3,4} i For j=1 to 10 with step 1
| Yo Write "dome data: “,i,j
ItevACi,s31i {6,8,7} : Yo read a(i,j)
i FinParo
_ ।_____FiwPak r ¡ P {9,6,5}} EndFor
For i-1 to 10 With Step 1
, Pel s:8,0,21,0,20 i:1,2,3 | s<-0
i For j=1 to 10 with step 1
-Po.a is Wosta 10cne) .
6—0 j:1,2,3,1,2,3,1,2,3 i se-s+a(i,j)
j FinPara
4Po1q 51 hostq 1O Cic) 1
- . 5—5+AC/ i For j-1 to 10 with step 1
--fpb.d | j Write a(i,1)
- . Caco j - 1 hogte do-(ie)— j FinPara
. ervkcA0.52 : Write "The sum of this row is: ",s
___fw po vo
. esebt _ (Iosome by esteveglewes,",s)
°scelbc (5ALro bE LINE
; Write jump
EndFor
fn eat- _ TL nAunt EndAlgorithm
_feuming-

Screen Execution in PSEINT

1 §88Yo*
, .... - or :gerrI:ITI: $ i ; MMH r Mjl !iiih

Yo: !
Yo

1
Program that writes the sum at the end of each row
Give me data 1.1
1
Give me data 1,2
3
Give me data 1,1 4
4
Give me data 2.1
6
Give me data 2.2
8
Give me data 2.3
7
Give me data 3.1
9
Give me data 3.2
6
Give me data 3.3
5
1 3 4Theaddition of this row
It's 8
6 8 7Theaddition of this row
It's 21

6
6
Literature
1. Albarrán Trujillo SE, Salgado Gallegos M, Structured Programming, UAEM, 2010. ISBN. 978-607-422-127-5.

2. Cairó, Osvaldo, Programming Methodology, Volumes I and II, Computec, Colombia, 2006. ISBN. 978-9701511008.

3. Cairó, Osvaldo. Programming Fundamentals. Think C, Pearson Education, 2006. ISBN. 978-9702608103..

4. Juan Carlos House. Introduction to Programming: Entering the World of Programming (Introduction to Programming
Collection)
programming no. 3). Ed. Creative Andina Corp; 2012. ASIN: B00IP0159C

5. Gorka Urrutia Landa. C Programming Course for Beginners: Learn to Program in C from Scratch. Kindle Edition.
2012, 3rd edition. ASIN: B006J9SXVE

6. Joyanes, Aguilar Luis, Programming in C, McGraw Hill, Mexico, 2010. ISBN-10: 6071512123. ISBN-13: 978-6071512123.

7. Joyanes, Aguilar Luis, Algorithms, Programming and Data Structures, McGraw-Hill Interamericana, February 2006. ISBN 978
8448145149

8. Joyanes, Aguilar Luis, C++ Programming, McGraw-Hill, ISBN 978-8448146436

9. Smith John, Programming Fundamentals Applied to C#: The Essential Manual for Getting Started in the World of
Programming
development of computer applications in C#, ed. CreateSpace. October 2015, ASIN: B0179VR0AA.

10. Zavala Lopez Raul Antonio, Llamas Avalos Roberto. Programming fundamentals for beginners. Kindle Edition, 2013. ASIN:
B00CW4Q94I.

6
7
L Annex I
PSEINT Instructions
Operators:
Operator Meaning Example
Relational
> Greater than 3>2
< Less than 'ABC
= Same as 4=3
<= Less than or equal to 'a'<=b
>= Greater than or equal to 4>=5

Logical
&ÓY Conjunction (and). (7>4) & (2=1)//false
|OO Disjunction (or) (1=1 | 2=1) //true
~ or NOT Denial (no) ~(2<5) //false
Algebraic
+ Addition total <- cantl + cant2
- Subtraction stock <- disp - sale
* Multiplication area <- base * height
porc <-100 * part / whole
/ Division

TO Empowerment sup <- 3.41 * radius * 2

% or MOD Module (remainder of integer remainder <- num MOD div


division)

Operators in PSEINT

6
8
PSEINT Functions

6
9
To review the PSEINT control structure instructions, it is recommended to review:

E https://es.slideshare.net/ronald73k/clase04-tutorial-pseint-5744163

https://es.scribd.com/document/288684623/Pseint-Tutorial

7
0

You might also like