Top-Rated Free Essay
Preview

Repition Control Structure

Good Essays
530 Words
Grammar
Grammar
Plagiarism
Plagiarism
Writing
Writing
Score
Score
Repition Control Structure
1. What is repetition control structure?

Repetition control structure is also known as looping or iteration control structure. .Repetition is the act of repeating steps in a certain process. It consists of a branching backwards away from the normal sequence of steps towards an earlier step. The branching decision is based on a relationship between the values of known data (condition) at the time that the branching test is performed. The condition is usually based on the value of a single variable (control variable). The steps to be repeated are referred to as the loop body. Each execution of the steps is referred to as a pass or iteration. The step where the body starts is called as the loop entrance and the step where the test branches back fails is known as the loop exit, it causes the repetition to stop.

It is a process of executing one or more steps of an algorithm or program repeatedly. Repetition is needed to add a list of numbers or variables for each number and one for the total would need to be declared. For a different number of values, recoding would be required. C++ has three repetition structures that repeat statements over and over until certain conditions are met. Repetition control system is very essential in programming for most programs do repetitious tasks.

2. What are the different types of repetition control structure?

The two basic types of loops are pre-test loop and the post-test loop.

PRE-TEST LOOP The pre-test loop can be put to in VB with a "Do" statement followed by either the keyword "While" or "Until". "Do While" means execute the statements entered in the body of the loop While a certain condition is true. "Do Until" means execute the statements in the body of the loop until a certain condition is true. While and Until are opposite to each other, doing something Until a condition is TRUE is the same as doing something While a condition is FALSE. Do While X 10. In C++, while is a reserved word. The expression acts as a decision maker. It is called the loop condition. The statement can be either a simple or compound statement. It is called the body of the loop.

[pic]

The While/Wend Loop- it is an older statement pair from previous versions of BASIC and was included in VB for compatibility. The format is:

While Wend The following two code segments produce the exact same results: |intNum = Val(InputBox("Enter a number")) |intNum = Val(InputBox("Enter a number")) |
|Do While intNum > 0 |While intNum > 0 |
| intNumSq = intNum ^ 2 | intNumSq = intNum ^ 2 |
|Print intNum; "squared is"; intNumSq | Print intNum; "squared is"; intNumSq |
| intNum = Val(InputBox("Enter a number")) | intNum = Val(InputBox("Enter a number")) |
|Loop |Wend |

There is no "Until" equivalent of "While/Wend"

The For/Next Loop – it uses a built-in counting procedure to repeat a series of instructions a specific number of times. Let us compare counting with Do/Loop vs. counting with For/Next. With Do While, you could set up a loop to print the numbers from 1 to 5 as follows:

intCounter = 1 Do While intCounter

You May Also Find These Documents Helpful

  • Satisfactory Essays

    What is procedural or algorithmic programming? What is object-oriented programming? What is the role of code reuse in object-oriented programming? Under what circumstances is object-oriented programming best suited? Under what circumstances is procedural or algorithmic programming best suited?…

    • 503 Words
    • 3 Pages
    Satisfactory Essays
  • Satisfactory Essays

    PT2520 Unit7Labs Tramil

    • 330 Words
    • 1 Page

    1. What does redundancy refer to? Redundancy refers to repeating the same data more than once; It occurs in a number of ways such as the data could be repeated over and over again in the same file.…

    • 330 Words
    • 1 Page
    Satisfactory Essays
  • Better Essays

    Olzak, T. (2010, July 5). The future of iris scanning. Retrieved November 2013, 2013, from A Tech Republic Website: http://www.techrepublic.com/blog/it-security/the-future-of-iris-scanning/…

    • 1902 Words
    • 8 Pages
    Better Essays
  • Satisfactory Essays

    Unit 7 Assignment 1

    • 261 Words
    • 2 Pages

    2. A pretest loop is a loop tests the conditions before performing the iteration. A posttest loop performs the iteration then test the condition.…

    • 261 Words
    • 2 Pages
    Satisfactory Essays
  • Powerful Essays

    Mat 540 Week 4 Paper

    • 1775 Words
    • 8 Pages

    A worm is moving toward an apple. Each time it moves, the worm cuts the distance between itself and the apple by its own body length until the worm is close enough to enter the apple. The worm can enter the apple when it is within a body length of the apple.…

    • 1775 Words
    • 8 Pages
    Powerful Essays
  • Satisfactory Essays

    Pt1420 Assignment

    • 1058 Words
    • 5 Pages

    A condition-controlled loop uses a true/false condition to control the number of times that it repeats…

    • 1058 Words
    • 5 Pages
    Satisfactory Essays
  • Powerful Essays

    EAS230Syllabus

    • 1748 Words
    • 8 Pages

    C++ programming: editing, compiling, user I/O, variables (ints, doubles, char, strings, booleans), loops, decisions, functions, pointers, arrays, tables, databases, sorting.…

    • 1748 Words
    • 8 Pages
    Powerful Essays
  • Satisfactory Essays

    Positional Notation: Quiz

    • 518 Words
    • 4 Pages

    a repetition of n times. If you put {n,m} it means it repeats a minimum of ‘n’ and the maximum of ‘m’…

    • 518 Words
    • 4 Pages
    Satisfactory Essays
  • Good Essays

    Closed Loop Control

    • 488 Words
    • 2 Pages

    Closed loop control is a theory of motor control that involves an executive, comparator, and effector components. The steps in the closed loop schematic diagram starts off with the input (stimuli) which then goes through info processing. the info processing is the executive stage and within this stage there are three different process that occur. The first process is the Stimulus identification, which identifies what it is. Then after is the response selection and then follows the response programming. After comes the output which leads into the effectors, or muscle glands. Also coming from the output is the desired state which leads to the cerebellum. From the muscle glands there are two types of feedbacks. The two types of feedbacks are interceptive and exteroceptive. These both lead up to the cerebellum, also known as the comparator, the third component. The comparator receives info about the desired state and actual state and compares. After comparing it goes through motor error and then updates the stimulus identification.…

    • 488 Words
    • 2 Pages
    Good Essays
  • Good Essays

    Traditional learning viewpoints considered classical and operant conditioning to be automatic processes involving only environmental events that did not depend at all on biological or cognitive factors. Research on which of the following concepts cast doubt on this point of view?…

    • 2606 Words
    • 20 Pages
    Good Essays
  • Good Essays

    * Having each section repeated (structure) – when in Binary form (two sections to a movement), was very common…

    • 3080 Words
    • 13 Pages
    Good Essays
  • Good Essays

    Macro Examples

    • 1120 Words
    • 5 Pages

    1. Do…Loops are used in macros to repeat lines of code until or while a specified condition is met.…

    • 1120 Words
    • 5 Pages
    Good Essays
  • Powerful Essays

    Motor Learning

    • 23222 Words
    • 93 Pages

    3. Open-loop motor control relies on sensory feedback to guide the completion of the movement.…

    • 23222 Words
    • 93 Pages
    Powerful Essays
  • Good Essays

    5. What distinguishes a Loop control construct from a While control construct, in terms of what is known about the number of times the block of code will be repeated?…

    • 610 Words
    • 3 Pages
    Good Essays
  • Satisfactory Essays

    internal control

    • 369 Words
    • 3 Pages

    a) Select two companies where inadequate internal control have resulted in disastrous effects on the organisation or exposed it to heavy losses.…

    • 369 Words
    • 3 Pages
    Satisfactory Essays

Related Topics