Professional Documents
Culture Documents
Tugas 1
Tugas 1
8
Flowchart exercises and examples
• How do the values of x and y change Start
during the process, if the input is 10?
in: x
• What is the output, if the input is 60?
• What does this algorithm do? y=2
9
Flowchart exercises and examples
This flowchart describes the algorithm of
calculation of the remain of a division.
Complete it.
false
• Start true
• a<=b
• a<0
• b<=0 false true
• a=a-b
false true
• in: a, b
• out: error
• out: a
• End
10
Pseudocode exercises
input a • What is the output if a=10?
if a<0 then • What is the output if a=-4?
b=-1*a • What does the algorithm do?
else
b=a • What does this algorithm do?
endif
input a
output b
if a<0 then
a=-1*a
endif
output a
12
Pseudocode exercises
input a • Do the pseudocode and the flowchart
input b describe the same algorithm?
c=a
if b>0 then Start
b=b-1 in: a, b
c=c-1
else c=a
output c
endif false b>0 true
out: c b=b-1
End c=c-1
13
Pseudocode exercises
input a • How do the values of a, b and c
input b change during the process,
c=a if a=7 and b=3?
while b>0 do • What is the output in this case?
b=b-1 • How many times will the
c=c-1 condition evaluated?
enddo
• What does this algorithm do?
output c
• Convert it to flowchart.
14