Skip to main content

  | मौसम…

411 समाचार
Public archive edition · Attributed source reporting with original dates · AI drafts are excluded

411 REFERENCE · Wikibooks

Programming Fundamentals/Iteration Control Structures

Reference material by Wikibooks contributors. This retains its source identity and is not 411 news reporting.

Overview In iteration control structures, a statement or block is executed until the program reaches a certain state, or operations have been applied to every element of a collection. This is usually expressed with keywords such as while, repeat, for, or do..until.Wikipedia: Structured programming Discussion The basic attribute of an iteration control structure is to be able to repeat some lines of code. The visual display of iteration creates a circular loop pattern when flowcharted, thus the word “loop” is associated with iteration control structures. Iteration can be accomplished with "test before" loops, "test after" loops, and counting loops. A question using Boolean concepts usually controls how often the loop will execute. Pseudocode: Iteration (Repetition) Control Structures While Loop count assigned zero While count < 5 Display "I love computers!" Increment count End Do-While Loop count assigned five Do Display "Blast off is soon!" Decrement count While count > zero Repeat-Until Loop count assigned five Repeat Display "Blast off is soon!" Decrement count Until count < one For Loop For x starts at 0, x < 5, increment x Display "Are we having fun?" End References cnx.org: Programming Fundamentals – A Modular Structured Approach using C++