Break
-
C++ break, continueVisual Studio/C++ 기초 2013. 10. 8. 00:35
프로그램을 작성할 때 가장 많이 사용하는 제어문은 선택문과 반복문입니다. 하지만 좀 더 세밀하게 제어하기 위한 방법이 필요한데 바로 break, continue return 문이 이러한 역할을 해 주는 제어문입니다. break 먼저 break문은 for, while, do-while과 같은 반복문이나 switch문을 탈출하는 데 사용합니다. break의 기능은 가장 가까운 반복문 또는 switch문을 탈출합니다. 먼저 예제를 보겠습니다. #include using namespace std; void main() { int sum = 0; for(int i=0; i
-
C언어 반복문제어 (break, continue, goto)Visual Studio/C 기초 2012. 9. 8. 17:20
break 반복문인 while, do-while, for문에 대해 배웠죠? 필요에 따라선 제어할 필요가 있습니다. break, continue 문을 사용하면 됩니다. for(count = 0; count 10) goto start; //start로 갑니다. else if(n==0) goto location0; //location0으로 갑니다. else if(n==1) goto location1; //location1로 갑니다. else goto location2; //locaiont2로 갑니다. location0: puts("당신은 0을 입력하였습니다.\n"); goto end; location1: puts("당신은 1을 입력하였습니다.\n"); goto end; location2: puts("당신은 2..