Iteration: Difference between revisions
From Coderwiki
More actions
new |
add: links to definite and indefinite iteration |
||
| (3 intermediate revisions by the same user not shown) | |||
| Line 4: | Line 4: | ||
There are two main forms of loops in [[Programming language|programming languages]]: | There are two main forms of loops in [[Programming language|programming languages]]: | ||
* '''Count''' controlled: [[for loop]] | * '''Count''' controlled: [[for loop]] or [[foreach loop]] - see [[definite iteration]]. | ||
* '''Condition''' controlled: [[while loop]] | * '''Condition''' controlled: [[while loop]] or [[do while loop]] - see [[indefinite iteration]]. | ||
== Iteration and recursion == | |||
[[Recursion]] is a programming technique that often achieves the same thing as iteration. In some cases, it can be a better option than iteration. | |||
Latest revision as of 09:24, 15 August 2025
Iteration is essentially looping.
Loops generally involve repeating some code a certain number of times, or until a condition is met.
Types of iteration
edit edit sourceThere are two main forms of loops in programming languages:
- Count controlled: for loop or foreach loop - see definite iteration.
- Condition controlled: while loop or do while loop - see indefinite iteration.
Iteration and recursion
edit edit sourceRecursion is a programming technique that often achieves the same thing as iteration. In some cases, it can be a better option than iteration.