Title: INF 165 Delphi
1INF 165 - Delphi
2Class Outcomes
- Repetition Structures
- FOR loop
- WHILE loop
- REPEAT loop
- Accumulator and Flag variables
- Ordinal Routines
3Repetition - FOR loops
Determinate (or definite) loop structure
for counter start to finish do begin
statements end
for counter start downto finish do begin
statements end
4Repetition - FOR loops
counter start
Is counter gt finish
Yes
Continue with the code
No
Body of loop
Increment counter
5Repetition - FOR loops
var counter integer sum
integer begin sum 0 for counter 1 to
100 do begin sum sum counter
end end
6Repetition While loop
Indeterminate (or indefinite) loop structure
while condition do begin
statements end
7Repetition While loop
Is condition True?
Yes
Continue with the code
No
Body of loop
8Repetition While loop
sum 0 count 1 while (count lt 100) do
begin sum sum count count count
1 end
If count is not incremented it will result in an
endless loop.
9Repetition Repeat loop
Indeterminate (or indefinite) loop structure
repeat statements until condition
10Repetition Repeat loop
Body of loop
Is condition True?
Yes
Continue with the code
No
11Repetition Repeat loop
sum 0 count 1 repeat sum sum
count count count 1 until (count gt
100)
If count is not incremented it will result in an
endless loop.
12Flag variables
- A Flag is a variable (typically a Boolean
variable) that indicates the presence (or
absence) of a condition.
var myStop boolean repeat
ShowMessage(hello world) myStop
cbxStop.checked until myStop
13Ordinal Values
- Ordinal types include integer, character,
Boolean, enumerated, and sub-range types. - An ordinal type defines an ordered set of values
in which each value except the first has a unique
predecessor and each value except the last has a
unique successor. - Further, each value has an order, which
determines the ordering of the type.
14Ordinal Routines
15Ordinal Routines