Sequence (順次) is a control structure that runs steps one at a time, top to bottom, in the order they are written.
Store 5 in a
Store 3 in b
Display the sum of a and b
The last step displays the sum, 8, and processing ends. Nothing branches or loops back along the way.
3 / 3
An algorithm (アルゴリズム) is a procedure of processing steps that achieves a goal, and any procedure can be built from three basic control structures (基本制御構造): sequence plus selection and iteration (the structured program theorem). A sequence has no branches and no returns, so processing follows one straight path.
AnalogyIt is like making instant noodles: pour in hot water, wait, then peel back the lid, in exactly the order printed on the cup.
Exam points
ExamAn algorithm (アルゴリズム) is the processing procedure itself for achieving a specific goal. Writing it in a different language does not change what the procedure does.
ExamSeveral steps placed inside a loop also run in sequence (順次), and each pass runs them again from the top in the same order.
Selection (選択) is a control structure that switches the next step depending on whether a condition (条件) holds (true) or does not hold (false).
Score 80 or higher?
True: grade A
False: score 60 or higher?
True: grade B
False: grade C
The second condition decides between grade B and C. Nesting selections lets you split processing into three or more cases.
3 / 3
Selection is also called branching (分岐); in a diagram, one line leaves the diamond-shaped decision (判断) symbol for each result, such as true and false (Yes and No). Placing one selection inside another divides processing into three or more paths.
AnalogyIt works like a station ticket gate: a valid ticket opens the gate, and an invalid one keeps it shut.
How to rememberPrograms usually write a selection starting with the word if.
Exam points
ExamWhen one selection (選択) is placed inside another (nesting), the inner condition on the side the outer condition leads to splits processing further.
ExamWhen decisions (判断) are stacked vertically to sort data into categories, checking the categories with more matching items first reduces the total number of comparisons.
Iteration (繰返し) is a control structure that runs the same block of steps (the body, 本体) again and again while checking a condition; it is also called a loop (ループ).
← Scroll the figure sideways →
Depending on where the condition is checked, there is the pre-test loop (前判定), which checks before the steps, and the post-test loop (後判定), which checks after them. A condition can be written as a continuation condition (継続条件), which keeps the loop going while it holds, or as a termination condition (終了条件), which exits once it holds. For a loop with a set number of passes, you specify the variable's initial value (初期値), increment (増分), and final value (終値).
AnalogyIt is like climbing stairs: check whether there is another step above, climb it if there is, and stop when none are left.
How to rememberA loop is literally a ring, and in a diagram drawn with a decision the arrow curves back up like one, so the same range is passed through again.
Exam points
ExamTo find the result of a loop (繰返し), write down the variable values pass by pass and stop at the pass where the exit check holds.
ExamIn a loop (繰返し) that counts up by 1, the number of passes depends on the counter's initial value (初期値) combined with the boundary of the exit check (less than, or less than or equal to). Shifting either one by 1 shifts the count by one pass.
ExamIn a loop (繰返し) that steps a variable from its initial value (初期値) by an increment (増分) up to its final value (終値), the series of values it takes (for example 1, 5, 9 when going from 1 to 9 in steps of 4) feeds the calculation in the body.
A flow diagram (流れ図) shows processing steps as standard symbols joined by arrows (flow lines).
Symbol
Shape
Meaning
Terminal
Wide shape with rounded ends
Start and end
Process
Rectangle
Processing such as calculation or assignment
Decision
Diamond
A fork based on a condition
Loop limit
Rectangle with clipped corners (paired top and bottom)
Start and end of a loop
Flow line
Line or arrow
Direction of processing
The main symbols include, for example, the terminal (端子) for start and end, the process (処理) for calculations, the decision (判断) that splits the path by a condition, and the loop limit (ループ端) placed above and below the repeated range. The basic reading direction is top to bottom and left to right, and arrows mark any other direction. The three basic control structures appear as symbols linked vertically, as a split at a decision, and as a range enclosed by loop limits (or an arrow from a decision back upward).
AnalogyIt is like a route map that marks forks and detours with fixed symbols and uses arrows to show which way to go.
Exam points
ExamA loop limit (ループ端) holds either the condition of the loop (繰返し) or the variable's initial value (初期値), increment (増分), and final value (終値). When the condition is written as a termination condition (終了条件), it is checked at the loop limit, and the loop exits once it holds.
ExamTo get the result of a flow diagram (流れ図), follow each data item along the lines through the branches at each decision (判断). Data that goes down one branch never passes the decisions on another branch.
A flowchart (フローチャート) is the English name for the flow diagram (流れ図), and both refer to the same diagram.
Only the name differs: the symbols and the way you read them are the same as for a flow diagram. It is used not only for program steps but also for mapping out how work proceeds.
How to rememberTranslate flow and chart word for word into Japanese and you get 流れ図.
Exam points
ExamA flowchart (フローチャート) uses symbols to draw the order and branching of processing, such as a program's, so that you can trace it.
Mix-upA data flow diagram (データフローダイアグラム, DFD) shows where data comes from, which processes it passes through, and where it is stored. A flowchart (フローチャート) shows the order in which processing is carried out.
Pseudocode (擬似言語) is a notation that describes an algorithm in a fixed, near-prose format, free from the grammar of any particular programming language.
Notation
Meaning
variable ← expression
Assign the value of the expression to the variable
if (condition) … else … endif
Selection
while (condition) … endwhile
Repeat while the condition holds (pre-test)
for (how the variable changes) … endfor
Repeat while changing a variable
○ type: name(arguments)
Function declaration (the type is that of the return value)
○ name(arguments)
Declaration of a procedure with no return value
return value
Finish and hand back the return value
In the format used in past exam questions from fiscal 2022 onward, assignment is written with ←, which puts the value of the expression on the right into the variable on the left. Selection is enclosed by if … endif, iteration by while … endwhile or for … endfor, and indentation marks the range of the body. In a function that groups processing together, the values it receives are called arguments (引数) and the value it returns is called the return value (戻り値).
AnalogyIt is like a recipe note written only with fixed symbols and phrases so that it works in any restaurant's kitchen.
How to remember擬似 means imitating the real thing: it is a way of writing that imitates a real programming language.
Exam points
Exam“a ← a × 2” is not an equation but an assignment (代入) that replaces a with twice its current value.
ExamThe condition of while is a continuation condition (継続条件): the body runs only while it holds, and once it no longer holds, processing moves past endwhile.
ExamWhen an if sits inside a for, the condition is checked on every pass: if it is true the if side runs, and if it is false the else side runs. Without an else, nothing between if and endif runs on a pass where the condition is false.
Enclosed by loop limits, or an arrow back to the check
Enclosed by while or for and its matching end word, with indentation
Key points
Any algorithm can be written by combining the three basic control structures: sequence, selection, and iteration.
流れ図 (flow diagram) and フローチャート (flowchart) are two names for the same diagram, which draws a procedure with symbols such as terminals, decisions, and loop limits.
In pseudocode, ← means assignment: the value of the expression on the right replaces the variable on the left.
In a loop with a set number of passes, the variable's initial value, increment, and final value determine how many passes run and which values the variable takes.