(3)Repetition structures
A “repetition structure” represents a flow which, based on some predetermined frequency or condition, is carried out over and over again as long
as some requirement is satisfied, or until some criteria has been met.
Start
Condition
True
When the flow repeats due to some
condition, there are methods which
judge the condition before the repetition
occurs ( pre-assessment ) , and also
methods which judge the condition after
the repetition takes place (post-assessment).
Basic theory
False
Condition based repetition
Chapter 7
Process ①
Reference
Process ②
End
3
Typical algorithms
The typical algorithms used are summarized below.
(1)Sum
A “sum algorithm” deals with addition. It is written using a sequence
structure if the number of additions ranges from one to several. If that
amount is always plural, however, it is written with a selection or repetition structure. Sum algorithms are the most standard type of algorithm.
Calculate “1 + 1”: y = y + x
① Assign
“0” to the value y (Default)
y=0+x
② Assign “1” to the value x
y=0+1
③ Assign the calculated result to the solution y
1=1
④ Assign “1” to the value x
y=1+1
⑤ Assign the calculated result to the solution y
2=2
⑥ Repeat steps ④ and ⑤ if further calculations are necessary.
176