Processing math: 100%
Skip to main content
Library homepage
 

Text Color

Text Size

 

Margin Size

 

Font Type

Enable Dyslexic Font
Engineering LibreTexts

5.7: Loop patterns

( \newcommand{\kernel}{\mathrm{null}\,}\)

Often we use a for or while loop to go through a list of items or the contents of a file and we are looking for something such as the largest or smallest value of the data we scan through.

These loops are generally constructed by:

  • Initializing one or more variables before the loop starts
  • Performing some computation on each item in the loop body, possibly changing the variables in the body of the loop
  • Looking at the resulting variables when the loop completes

We will use a list of numbers to demonstrate the concepts and construction of these loop patterns.


This page titled 5.7: Loop patterns is shared under a CC BY-NC-SA license and was authored, remixed, and/or curated by Chuck Severance.

  • Was this article helpful?

Support Center

How can we help?