![]() The name for-loop comes from the word for. There are other possibilities, for example COBOL which uses "PERFORM VARYING". Various keywords are used to indicate the usage of a for loop: descendants of ALGOL use "for", while descendants of Fortran use "do". For-loops can be thought of as shorthands for while-loops which increment and test a loop variable. For-loops are typically used when the number of iterations is known before entering the loop. This allows the body to know which iteration is being executed. The header often declares an explicit loop counter or loop variable. ![]() The header defines the iteration and the body is the code that is executed once per iteration. ![]() Specifically, a for loop functions by running a section of code repeatedly until a certain condition has been satisfied.įor-loops have two parts: a header and a body. In computer science a for-loop or for loop is a control flow statement for specifying iteration. ![]()
0 Comments
Leave a Reply. |