Iteration: FOR · 반복: FOR
This page needs a recent browser (with SharedArrayBuffer support). Please update Chrome, Edge, Firefox or Safari to the latest version. · 이 페이지는 최신 브라우저(SharedArrayBuffer 지원)가 필요합니다. Chrome, Edge, Firefox 또는 Safari를 최신 버전으로 업데이트해 주세요.
English
FOR counts
- A count-controlled loop runs once for each integer from the start to the end, inclusive.
- The counter is an
INTEGER. - It is good practice to repeat the counter's name after
NEXT.
한국어
FOR 카운트
- 카운트 제어 루프는 시작값부터 끝값까지(포함)의 각 정수마다 한 번 실행됩니다.
- 카운터는
INTEGER입니다. NEXT뒤에 카운터 이름을 반복적으로 사용하는 것이 좋습니다.
DECLARE Total : INTEGER
Total ← 0
FOR I ← 1 TO 5
Total ← Total + I
NEXT I
OUTPUT Total
Explore · 탐색하기
Trace the running total · 총합 추적하기
A FOR loop repeats a set number of times. Step through and watch Total grow. · FOR 루프는 지정된 횟수만큼 반복됩니다.Total이 커지는 과정을 단계별로 확인하십시오.
English
STEP changes the jump
STEPsets the gap between values. It can be negative.- If the start is already past the end in the step's direction, the body does not run.
한국어
STEP 점프 변경
STEP는 값 사이의 간격을 설정합니다. 음수가 될 수 있습니다.- 시작값이 단계 방향에 이미 끝값을 넘어서면 본체가 실행되지 않습니다.
FOR I ← 5 TO 1 STEP -2
OUTPUT I
NEXT I
English
Watch out
NEXT Imust name the counter of this loop.- The body is indented.
NEXTlines up withFOR.
한국어
주의사항
NEXT I는 이 루프의 카운터를 명명해야 합니다.- 본체는 들여씌워집니다.
NEXT는FOR와 정렬됩니다.
English
Common mistakes
1 TO 5includes both 1 and 5.- Do not change the counter yourself inside the body.
한국어
흔한 실수
1 TO 5는 1과 5 모두를 포함합니다.- 본체 내부에서 카운터를 직접 변경하지 마십시오.
English
Now you try
- Use a
FORloop to print a run of numbers.
한국어
이제 직접 해보기
- 숫자 일련을 출력하려면
FOR루프를 사용하십시오.
Use a FOR loop to output the numbers 1 to 5, one per line. · FOR 루프를 사용하여 숫자 1부터 5까지 줄마다 출력하십시오.
Click Run to see the output here. · 출력을 보려면 '실행'을 클릭하세요.
Output 5, 3 and 1, using FOR with STEP -2. · 5, 3, 1을 출력하시되, FOR을 STEP -2과 함께 사용하십시오.
Click Run to see the output here. · 출력을 보려면 '실행'을 클릭하세요.