Changes

Jump to navigation Jump to search
307 bytes added ,  17:19, December 2, 2008
for loop
Line 1: Line 1:  
A '''loop''' in [[Computer Programming]] is a section of instructions which are repeated - either endlessly or until a certain expected state occurs.
 
A '''loop''' in [[Computer Programming]] is a section of instructions which are repeated - either endlessly or until a certain expected state occurs.
 +
A common error made by novice programmers is to program an infinite loop, i.e., one that never ends despite the programmer's hopes.
 +
 +
Fortran introduced the do loop, which BASIC made into the for loop. A counter is given an initial value. If it is below the maximum value, the loop's instructions are executed. Then the counter is set to the next value.
 +
 +
This example prints out the first five integers:
 +
FOR I = 1 TO 5
 +
  PRINT I
 +
NEXT I
 +
   −
A common error made by novice programmers is to program an infinite loop, i.e., one that never ends despite the programmer's hopes.
   
[[Category:Computer Programming]]
 
[[Category:Computer Programming]]
Siteadmin, Check users, nsTeam1RO, nsTeam1RW, nsTeam1_talkRO, nsTeam1_talkRW, oversight, Administrators
30,650

edits

Navigation menu