• Join over 1.2 million students every month
  • Accelerate your learning by 29%
  • Unlimited access from just £6.99 per month

Selection Control and Repetition Control Structure

Extracts from this document...


Selection Control and Repetition Control Structure University of Phoenix Mayada Set PRG/210 Fundamental of Programming with Algorithm and Logics Instructor Name: Guillermo A. Hernandez Date: May 15, 2009 Before writing a program to solve a problem, we must have a thorough understanding of the problem and a carefully planned approach to solving it. When writing a program, we must also understand the types of building blocks that are available and employ proven program construction techniques. A computer can process a program in one of three ways: in sequence; selectively by making a choice, which is also called a branch; or repetitively by executing a statement over and over, using a structure called a loop. Control structures provide alternatives to sequential program execution and are used to alter the sequential flow of execution. The two most common control structures are selection and repetition. In selection, the program executes particular statements depending on some condition(s). In repetition, the program repeats particular statements a certain number of times depending on some condition(s). ...read more.


When neither condition is true, then the combined condition is considered false. - Nested selection is used for multiple cases by placing if.......else selection statements inside other if.........else selection statement. For example: If student_grade >= 90 then Print "A" Else If student_grade >= 80 then Print "B" Else If student_grade >= 70 then Print "C" Else If student_grade >= 60 then Print "D" Else Print "F" Endif Endif Endif Endif Note that there are an equal number of IF, ELSE and ENDIF statements, that each ELSE and ENDIF statement is positioned so that it corresponds with its matching IF statement, and that the correct indentation makes it easy to read and understand. The other type of structure control is repetition control. The repetition structure is a bit more complicated than the selection structure, but it is easy to understand. A repetition structure consists of a block of statements that are executed repetitively. They might be executed once or a hundred times depending on the controls placed on the structure. ...read more.


If the condition is false, the statements will be repeated UNTIL the condition becomes true. The format of the REPEAT...UNTIL structure is: REPEAT statement statement . . UNTIL condition is true Counted repetition occurs when the exact number of loop iterations is known in advance. The execution of the loop is controlled by a loop index, and instead of using DOWHILE, or REPEAT...UNTIL, the simple keyword DO is used as follows: DO loop_index = initial_value to final_value statement block ENDDO The DO loop does more than just repeat the statement block. It will: 1. initialize the loop_index to the required initial_value 2. increment the loop_index by 1 for each pass through the loop 3. test the value of loop_index at the beginning of each loop to ensure that it is within the stated range of values 4. terminate the loop when the loop_index has exceeded the specified final_value. . Reference: 1. Simple Program Design: A Step by Step Approach, Chapter 4, 5e by Lesley Anne Robertson. 2. Simple Program Design: A Step by Step Approach, Chapter 5, 5e by Lesley Anne Robertson ?? ?? ?? ?? Selection and Repetition Control Structure 1 ...read more.

The above preview is unformatted text

This student written piece of work is one of many that can be found in our University Degree Engineering section.

Found what you're looking for?

  • Start learning 29% faster today
  • 150,000+ documents available
  • Just £6.99 a month

Not the one? Search for your essay title...
  • Join over 1.2 million students every month
  • Accelerate your learning by 29%
  • Unlimited access from just £6.99 per month

See related essaysSee related essays

Related University Degree Engineering essays

  1. Process Control

    Integral term The contribution from the integral term is proportional to both the magnitude of the error and the duration of the error. Integrating the error gives offset that should have been corrected previously. The accumulated error is then multiplied by the integral gain and added to the controller output.

  2. The Simple Pedulum

    * Yes the period depends on the amplitude because the larger the angle or displacement, the larger the period. if the angle of amplitude is less the period also becomes less because the pendulum stops swinging at a short period of time.

  1. Design of a Thermal Control Regime

    PROBLEM STATEMENT & RESULTS Part I: Steady-State Simulation The first half of this project simulated the heat transfer of a hypothermia bed using a steady-state simulation, a scenario in which all heat transferred to the patient is in turn transferred to the environment through convection and radiation.

  2. Bytronic Pendulum Control System

    The position of pendulum bob (y), the position of the carriage (x) and the angle of the pendulum () are related by the equation: The L is the effective length of the pendulum, the distance between the pivot and the centre of mass of the combined pendulum and bob.

  1. Jigsaw redesign. We were assigned the task of evaluating and redesigning a given DIY ...

    The colors chosen were neither luminous nor attractive at first sight. The design of the box could have been made more appealing, possibly by using a different font and color scheme. The components that came with the jigsaw were also loose and fell right out of the box which could be easily lost and may cause hazard.

  2. Swimming Goggles Material Selection

    The table below shows some of the most common ones. Figure 1: Table Showing Some General Polymers [2] Name Formula Monomer Properties Uses Polyethylene low density (LDPE) -(CH2-CH2)n- ethylene CH2=CH2 soft, waxy solid film wrap, plastic bags Polyethylene high density (HDPE)

  1. Voice Encryption using RSA Algorithm

    Zulfiqar Ali Bungash and Mr. Ali Arshad who have guided us during the course of this project. Their valuable suggestions and discussions were a source of motivation for us. We are very grateful to Dr. Nazir A. Mir HoD Mathematics, CIIT Islamabad who helped us interfacing Maple kernel in MATLAB.

  2. Pharmaceutical Plant Design

    This implies that a careful study should be made of the several alternatives at each phase of the process and the course that has the greatest likelihood of providing the required service most economically in the long run adopted."4 Design has become a three-stage process: > Stage 1: pre-design sanction

  • Over 160,000 pieces
    of student written work
  • Annotated by
    experienced teachers
  • Ideas and feedback to
    improve your own work