In computer programming, a loop is a sequence of instructions that is continually repeated until a certain condition is reached or a condition is declared FALSE. Typically, a certain process is done, such as getting an item of data and changing it, and then some condition is checked such as whether a counter has reached a prescribed numberA unit of abstract mathematical system subject to the laws of arithmetic.. If it hasn't, the next instruction in the sequence is an instruction to return to the first instruction in the sequence and repeat the sequence. If the condition has been reached, the next instruction "falls through" to the next sequential instruction or branches outside the loop. A loop is a fundamental programming idea that is commonly used in writing programs.
An infinite loop is one that lacks a functioning exit routine . The result is that the loop repeats continually until the operating system senses it and terminates the program with an error or until some other event occurs (such as having the program automatically terminate after a certain duration of time) .
This is one of the better videos I've seen on loops. Content gratefully used with permission : . The video uses programming syntax from the C programming language, but the main ideas are helpful in understanding loops.
Do you understand this topic?
- DefineGive the precise meaning of a word, phrase, concept or physical quantity. a loop
- ListGive a sequence of brief answers with no explanation. two reasons why you might use a loop in a computer program
Do you have an advanced understanding about this topic?
- Write a program that uses loops to get something done
- Write a flowchart that uses loops in a normal decision (perhaps what's for dinner)
- ConstructDevelop information in a diagrammatic or logical form. algorithms using loops, branching.