While

    while 반복문을 종료하는 방법: 센티넬, EOF, 플래그

    카운터 제어 while 반복문 #include using namespace std; int main() { int counter = 0; while (counter > num; } cout > 연산자를 입력하면 된다. 이 연산자는 스트림에서 항목을 읽다가 EOF를 만나면 false를 리턴한다. //키보드 while(cin >> num) { ... } //파일 while(infile >> num) { ... } //키보드 입력 EOF로 반복 종료하기 #include using namespace std; int main() { int num; int sum{0}; while (cin >> num) { sum +..