Sei sulla pagina 1di 5

PUSAT PENGAJIAN DIPLOMA, UNIVERSITI TUN HUSSEIN ONN MALAYSIA (UTHM)

PRACTICAL INTRODUCTION TO ALGORITHM AND DATA STRUCTURE


3
(REPETITION STRUCTURE OF ALGORITHM)
LEARNING
OUTCOMES

DURATION
REQUIREMENT

At the end of this practical session, you should be able to:


1. Write an repetition structure of algorithm to solve problem and represent
the algorithm using flowchart and pseudocode
2. Test flowchart developed using Raptor Tool
2 hours

i.
ii.
iii.

INSTRUCTIONS

RAPTOR tool program (Get an available installer from


http://raptor.martincarlisle.com/)
Details user guide to use the program (Retrieve from
http://web.cerritos.edu/pnguyen/SitePages/cis103/labs/raptor/Raptor_User_
Guide.pdf)
Details
Raptor
Syntax
and
Semantics
(Retrieve
from
raptor.martincarlisle.com/RAPTOR%20Syntax%20and%20Semantics.ppt)

This session encompasses 2 part which are Guided Practical Tasks and
Practical Exercises.
In guided practical task, step by step instructions are given as a practices in
using Raptor tool for developing flow chart.
In Practical Exercises, answer all questions given and use Raptor to get a
validate flowchart.

TIPS (By Lt Col

1.

Tom Schorsch)

When determining whether to use a Loop statement or not, it is


helpful to keep in mind the following questions:

2.

Will you need to do something more than once?


(loop)
Can you compute how many times you must do it? (count-controlledloop)

When developing Loops in your program it is helpful to keep in


mind the following questions:

What do you want the loop to do?


How do you know the loop code will execute the correct number of times?
How do you know the loop will continue and then stop when it is supposed
to?
What does the loop code do each time it is executed?
What must be done before the loop starts to get ready for the loop?
What must be done after the loop is finished executing?

1 | DAT 13303 Lab Practical 3, Prepared by Mazniha binti Berahim

PUSAT PENGAJIAN DIPLOMA, UNIVERSITI TUN HUSSEIN ONN MALAYSIA (UTHM)

GUIDED PRACTICAL TASKS:


A pseudocode below is not complete in order to display the largest from five input
numbers from user, do the following steps to develop a repetition structure of flow chart:
Step 1: Complete the pseudocode below:
START
set i=1;
largest=0;
while (i <= ___________)
input number;
if (_______________< _____________) then
largest = ____________;
endif
i=i+1;
endwhile
Display largest;
END

Step 2: Identify the IPO (Input, Process and Output) for the above pseudocode by
complete the Table 3.1 below.
Table 3.1: IPO Analysis
Input

Process

Output

2 | DAT 13303 Lab Practical 3, Prepared by Mazniha binti Berahim

PUSAT PENGAJIAN DIPLOMA, UNIVERSITI TUN HUSSEIN ONN MALAYSIA (UTHM)

Step 3: Based on the IPO analysis in Step 2, add loop symbol and suitable input,
assignment and output symbols as Figure 3.1.

Step 4: Edit the content of the loop exit condition (at decision diamond) for a repetition
control structure. Enter the in the textbox a Boolean expression (in Figure 3.2)
that will be evaluated for symbol added at Step 3.
If the Boolean expression is true, the loop will exit. Otherwise, flow continues on
the No branch below the diamond and eventually to the top of the loop.
Please edit the other symbols as well to complete your flowchart.

Figure 3.1: Flowchart of Repetition Merged With Selection Control Structure


3 | DAT 13303 Lab Practical 3, Prepared by Mazniha binti Berahim

PUSAT PENGAJIAN DIPLOMA, UNIVERSITI TUN HUSSEIN ONN MALAYSIA (UTHM)

Figure 3.2: Edit Content of Loop Exit Condition


Step 5: Execute the completed flowchart. During execution, refer the Watch window and
complete this Table 3.2 in order to trace the repetition process. Check Master
Console window to get final result and evaluation status of your flowchart.
Table 3.2: Trace Table of Repetition Process

largest

Exit condition true?


(Yes or No)

4 | DAT 13303 Lab Practical 3, Prepared by Mazniha binti Berahim

Number

PUSAT PENGAJIAN DIPLOMA, UNIVERSITI TUN HUSSEIN ONN MALAYSIA (UTHM)

PRACTICAL EXERCISES:
1. (a)

(b)
2. (a)

(b)

Write a pseudocode for solve problem in calculate area of a rectangle. Obtain the
length and width of a rectangle from the user in order to solve the problem. If the length
and width are equal, display a message indicating that the figure is a square and ask
the user input another values.
Convert the Question 1(a) to flowchart using Raptor Tool.
Write a pseudocode for solve problem in calculate an average of three test scores for
five students in DAT 13303 course. Obtain the test scores from each student in
order to calculate their average. If the average score is 75% or more, display a
message indicating that they may proceed to the next class
Convert the Question 2(a) to flowchart using Raptor Tool.

SELF- LEARNING
Loops in Raptor (Available at https://www.youtube.com/watch?v=_BTRJjFZY2Y)

5 | DAT 13303 Lab Practical 3, Prepared by Mazniha binti Berahim

Potrebbero piacerti anche