This section contains 848 words (approx. 3 pages at 300 words per page) |
Computer programs use many kinds of structures, but a very common and important one is a loop, a sequence of statements that is executed multiple times, either until some condition holds true, or for a certain fixed number of times. The first kind of loop is called a DO-WHILE loop, because the loop executed while a certain condition remains true; the second kind of loop is called a FOR loop, because the loop executes for a certain number of times (such as 10 or 100, or some number determined by user input or prior computations).
A loop in a program is spoken of as having two parts, a head and a body; the head is the part that specifies the loop conditions (DO something WHILE x is less than 10; or FOR i equals 1 to 100, etc.), and the body is the actual sequence of statements that are executed as...
This section contains 848 words (approx. 3 pages at 300 words per page) |