Control Statement (제어문)


Selection Statement

: 두 개 이상의 실행 경로 중 선택 → 크게 if, swtich 문으로 나뉨

if E1 goto 1
if E2 goto 2 
...
1: S1
goto out
2: S2
goto out
... 
out: ...
// C에서는 이런식으로 작성
case 
when count < 10 then bag1 = true
when count < 100 then bag2 = true 
when count < 1000 then bag3 = true 
end
// 이런식으로 사용하는 경우도 있다. case, when 동시에
(COND
    ((> x y) "x is greater than y")
    ((< x y) "y is greater than x")
    (ELSE "x and y are equal")
)

Iteration Statememt

: 0번 이상 실행되는 문장이다.

→ for, while(loop) 크게 두가지로 갈림 + DataStructure

Counter-Controlled Loops (=for)

for (expression_1; expression_2; expression_3) 
		loop body
// c의 for

Logically Controlled Loops (=while)