• 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. Bytronic Pendulum Control System

    to the servo amplifier input (terminal H) and measuring position with a scale or tape measure. The data below is retrieved from experiment which to compare between the displacement of carriage and Pico scope voltage. However, it was found that the data of the displacement of carriage are proportional to the Pico scope voltage.

  2. Pharmaceutical Plant Design

    They are often centrally placed (but not necessarily together)12 so that site expansion can proceed in all directions, providing the services will not later become part of a hazardous area. Service distribution should run parallel to roadways and not pass through plant areas.12 Water mains must be buried deeply enough to prevent freezing.

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

    each of these five methods, we did use two of them, Survey and field training. We drew up a survey between the five of us, each suggesting questions that we thought would be relative to ask. A sample of the survey is given at the end.

  2. 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.

  1. 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.

  2. Design of a Thermal Control Regime

    When the average temperature becomes higher than desired, the initial temperature is set to the "off" setting. When the average temperature drops too low, the initial temperature is increased to the "on" setting. ?: Emissivity mw: Mass flow rate T?: Air temperature ?: Stefan-Boltzmann P*: Equivalent channel width Tout: Out-going

  1. Computer Operations, Solving Problem and Algorithm

    If the output is to be written to the screen, the words Put, Output or Display are used in the pseudocode. An output Prompt instruction is usually required before an input Get instruction. The Prompt verb is used when information is sent to the screen, which requires the user to respond, usually by providing input.

  2. Thermal processing of food

    There are several methods of food freezing, but regardless the method chosen, the main principle behind all freezing processes is the same in terms of process parameters. The International Institute of Refrigeration (IIR) has divided the freezing process into three stages based on major temperature changes in a particular location

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