You are on page 1of 24

Chapter 05

조건문
Conditional Statements

01 if 문 if statement

02 중첩 if 문 nested if statement

03 switch~case 문 switch~statement
Section 01 if 문 (1)
■ 기본 if 문 The default if statement
 조건이 참일 때와 거짓일 때 각각 다른 일을 수행
 Perform different tasks when the condition is true and when it is false

2/26
Section 01 if 문 (2)

3/26
Section 01 if 문 (3)

4/26
Section 01 if 문 (4)
 줄바꿈 함정 – [ 실습 5-2] 에서 7 행이 실행 된 이유
다음과 같이 줄바꿈을 수정하여 실행 Modify the line break to run

즉 5 행의 조건식이 거짓이므로 그 아래 문장인 6 행만 건너뛰고 7 행부터 실행함


That is, since the conditional expression of line 5 is false, only the line 6 below is skippe
d, and the line 7 is executed.

5/26
Section 01 if 문 (5)

6/26
Section 01 if 문 (6)
■ if~else 문

7/26
Section 01 if 문 (7)

8/26
Section 01 if 문 (8)

9/26
Section 01 if 문 (9)

10/26
Section 02 중첩 if 문 (1)
■ 중첩 if 문

11/26
Section 02 중첩 if 문 (2)

12/26
Section 02 중첩 if 문 (3)

13/26
Section 02 중첩 if 문 (4)

14/26
Section 02 중첩 if 문 (5)

15/26
저자 한마디
■ 간소화한 중첩 if 문 Simplified nested if statement
 [ 실습 5-8] 의 11~23 행은 다음과 같이 더 간결하게 표현할 수도 있다 .
 Lines 11 to 23 of [Exercise 5-8] can be expressed more concisely as follows.

16/26
Section 03 switch~case 문 (1)
■ switch~case 문

17/26
Section 03 switch~case 문 (2)

18/26
Section 03 switch~case 문 (3)

19/26
Section 03 switch~case 문 (4)
 a가 3일 때
switch~case 문의 흐름도

20/26
Section 03 switch~case 문 (5)
 [ 실습 5-9] 에서 break 를 빼고 실행

21/26
Section 03 switch~case 문 (6)

22/26
Section 03 switch~case 문 (7)

23/26
Thank You

You might also like