Repetition Control Structure
Group 12
Muhammad Zulhafiz Bin Abu Kasim01DIP09F1002HONG HUEY LIAN01DIP09F1008NOOR AKMAR LIA BINTI KAMARUZAMAN01DIP09F1033
Lecturer’s Name : MDM. NORLIZA BT MOHAMED PIAH
The Repetition Control Structure
The repetition control structure is also known as the looping or iteration controlstructure. Looping is the process of repeatedly executing one or more steps of analgorithm or program; it is essential in programming, as most programs performrepetitious tasks.Every loop consists of the following three parts:(1) The loop termination decision - determines when (under what condition) theloop will be terminated (stopped). It is essential that some provision in theprogram be made for the loop to stop; otherwise, the computer wouldcontinue to execute the loop indefinitely - a loop that doesn't stop is called anendless loop or infinite loop; when a program gets stuck in an endless loop,programmers say that the program is "looping".(2) The body of the loop - the step or steps of the algorithm that are repeatedwithin the loop. This may be only one action, or it may include almost all of the program statements. Important note: some action must occur within thebody of the loop that will affect the loop termination decision at some point.(3) Transfer back to the beginning of the loop - returns control to the top of theloop so that a new repetition (iteration) can begin. There are two basic types of loops: the
pre-test loop
and the
post-test loop
.
Leave a Comment