Presentation is loading. Please wait.

Presentation is loading. Please wait.

Control Flow 요약.

Similar presentations


Presentation on theme: "Control Flow 요약."— Presentation transcript:

1 Control Flow 요약

2 Copyright © 2008 W. W. Norton & Company. All rights reserved.
for loop 구성 요소 초기값 제어구문 증가값 카운팅할 때 주로 사용되지만 용도가 많아 다양하게 활용됨 for (int cnt = 0, n = 5; cnt < n; ++cnt) odd += cnt; Copyright © 2008 W. W. Norton & Company. All rights reserved.

3 Copyright © 2008 W. W. Norton & Company. All rights reserved.
while 구성 요소 초기값 제어구문 증가값 조건이 참인지 검사하고 참인 경우에만 동작 int cnt = 0, n = 5; while (cnt < n){ odd += cnt cnt++; } Copyright © 2008 W. W. Norton & Company. All rights reserved.

4 Copyright © 2008 W. W. Norton & Company. All rights reserved.
do.. while 구성 요소 초기값 제어구문 증가값 조건 없이 1회 수행한 후 조건이 참인지 검사하고 참인 경우에만 동작 do{ printf(“hello\n”); } while (1); // 1: 참, 0: 거짓 결과: hello … (무한반복) Copyright © 2008 W. W. Norton & Company. All rights reserved.

5 Copyright © 2008 W. W. Norton & Company. All rights reserved.
break; continue break; 루프 밖으로 이동 한 루프 밖으로만 이동 continue; 루프 마지막으로 이동 동일한 루프에서 다시 시작 do{ printf(“hello\n”); break; printf(“world\n”); } while (1); do{ printf(“hello\n”); continue; printf(“world”); } while (1); 결과: hello 결과: hello … (무한반복) Copyright © 2008 W. W. Norton & Company. All rights reserved.

6 Copyright © 2008 W. W. Norton & Company. All rights reserved.
goto 지정된 레이블로 점프 do{ printf(“hello\n”); goto jumptohere; printf(“world\n”); } while (1); jumptohere: printf(“aha!”); 결과: hello aha! Copyright © 2008 W. W. Norton & Company. All rights reserved.


Download ppt "Control Flow 요약."

Similar presentations


Ads by Google