C언어 - 반복문


C언어 - 반복문

반복문 while문 - 조건 기반 반복문이다. (if문과 유사) - 예시 #include <stdio.h> int main(void) { int i = 0; while (i < 5) { printf("i = %d\n", i); i++; } return 0; } - 개행문자를 입력받을 때까지 입력 받은 것을 출력하는 예제 #include <stdio.h> int main(void) { char ch; while ( (ch = getchar()) != '\n') { putchar(ch); } return 0; } 무한루프 #include <stdio.h> int main(void) { int nInput; scanf_s("%d", &nInput); // 0입력 int i = 0; while (i >= nInput ) { // 무한루프, i가 정수 오버플로우 되면 종료됨 ++i; } return 0; } 반복문 - 반복문 내에서 변수 선언을 하면 안된다. (스택에 올라가고 내려가고를 반복...


#break #반복문 #무한루프 #while #knot #for #dowhile #c언어 #continue #c #인프런

원문링크 : C언어 - 반복문