• Embed Doc
  • Readcast
  • Collections
  • CommentGo Back
Download
 
Repetition Control StructureProgramming Principle
RepetitionControlStructure
Tutorial 3
 
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
.
 
Repetition Control Structure
The Pre-Test Loop
  The pre-test loop can be implemented in VB with a "Do" statement followed byeither the keyword "While" or "Until". "Do While" means execute the statements inthe body of the loop While a certain condition is true. "Do Until" means execute thestatements in the body of the loop Until a certain condition is true. While and Untilare opposites of each other. In other words, doing something Until a condition is TRUE is the same as doing something While a condition is FALSE. For example, DoWhile X <= 10 is the same as Do Until X > 10. Both the "While" and the "Until" versions of the pre-test loop are flowchartedbelow. The only difference between the two is the placement of the "True" and"False" paths extending from the decision diamond. 
of 00

Leave a Comment

You must be to leave a comment.
Submit
Characters: ...
You must be to leave a comment.
Submit
Characters: ...