Free Essay

Prg 210 Week 4 Paper

In:

Submitted By marsdawg
Words 1277
Pages 6
Selection and Repetition Control Structures

PRG 210
March 30, 2011
John Rogers

Selection and Repetition Control Structures
Introduction
This paper reviews and explains selection control structure and repetition control structure. Selection and repetition control structures increase the ability and power of a computer programs. Selection control structure allows statement execution if a condition is true and another statement execution if a condition is false. Repetition control structure or looping is the process of repeating execution of one or more steps of an algorithm or computer program. Essentially in programming, many performed calculations have repetitious tasks. Examples of both a selection control structure statement and a repetition control structure statement identifies and helps understand the importance of available computer operations to the programmer to compare variables, select one of two actions and repeat tasks as necessary.
Selection Control Structure
Statement executions in programming are under the control of one statement at a time. When statements execute, control is turned over to the next statement similar to running a relay race; one runner passes the baton to the next runner until the result of the baton across the finish line. When one statement finishes executing, control passes to the next statement until the desired output calculates. Computer programs use selection control structures to choose between alternative actions. An assumption is made based on whether it is true or false. If the statement is true it executes on one statement and if it is false it executes another statement. Computers can solve practical problems, make decisions and execute different sequences and instructions in such a way that it produces results faster and more accurate than human calculations. IF statements based on comparing two items usually expressed with one of the following relational operators.
|< |Less than | |Greater than |>= |Greater than or equal to | |
|= |Equal to | |Not equal to | |

Simple selections make a choice between two alternative paths, depending on the result of a condition being true or false. The structure represented in pseudo code using the keywords IF, THEN, ELSE, and ENDIF. For example, a teacher needs to provide to students whether or not he or she passed his or her class. A simple selection structure IF statement calculates the result (output).

The IF statement in pseudo code would look like this:

IF student _grade >= 60 THEN passed ELSE Failed ENDIF

Only one of the THEN or ELSE paths follows, depending on the result of the condition in the IF clause.
When a performed task and the particular condition is true, and no processing takes place with a false condition this is a null ELSE structure of the IF statement or a simple selection with a null false branch. Combined selection structure of the IF statement uses “AND” and “OR” connectors, which represents two conditions that have to be met before determining true or false.
In an IF statement and the statement contains the word IF more than once it is a nested selection. Nested selection IF statements can be linear or non-linear statements. A linear nested IF statement occurs when a field tests for various values and a different action is to be taken for each value. A linear statement contains ELSE immediately following the IF condition to which it corresponds. Non-linear nested IF statements occur when a number of different conditions are met before a particular action can occur. In a defined non-linear statement, the ELSE statement is separated from the IF statement with which it is paired. Repetition Control Structures
Many programs require the same repeated logic for several sets of data. A good way to accomplish this is to write code that can repeat the same set of logic over and over. Repetition control structure is known as the looping or iteration control structure. Executing one or more steps of an algorithm or program and repeating it is the process of looping. Repetition control structure is necessary in programming because most programs perform tasks that repeat several times. Every loop contains three parts; 1) the loop termination decision, 2) the body of the loop, and 3) Transfer back to the beginning of the loop. The loop termination decision determines when or under what condition the loop terminates or stops. The loop terminates otherwise the condition would allow the computer to continue the task over and over without stopping. The body of the loop is the step or steps of the algorithm that repeats within the loop, essentially all the tasks that need repeated within the pseudo code statement. Transfer back to the beginning of the loop returns control to the beginning of the loop so that a new repetition (iteration) can start.
Instructions repeat in three ways, each way determines where to place the repeated decision: beginning of the loop (leading decision loop), end of the loop (trailing decision loop), and (counted loop) counted number of times. In a leading decision loop the DOWHILE construct tests the condition before statement execution. In the following example of pseudo code the following flowchart identifies a DOWHILE loop,

Print_course_scores Read name, course_score DOWHILE course_score not >=61 Print name, course_score Read name, course_score ENDDO

Two considerations are taken when performing a lead decision loops. First perform some initial processing to set up the condition before testing and make sure a condition to render a false result is achievable in which ends the loop. A trailing decision loop uses the REPEAT and UNTIL structure. This type of loop tests the condition at the end of the loop. Trailing decision executed when the condition is false; it is only when the condition becomes true that the loop stops. Counted repetition happens when the exact number of loop iterations is known before the loop starts. The loop execution controlled by a loop index and the usages of a simple keyword DO. The DO loop can, 1) start the loop index to the required start value, 2) increase the loop index by one for each time the loop is run, 3) test the value of the loop index when the loop starts to make sure it stays within the range of values, and 4) terminate the loop once the loop index reaches the specified final value. Basically, a counted repetition automatically performs the initializing, incrementing, and testing of the loop. It also terminates the loop once the required amount of loop times is reached.
Conclusion
The paper reviewed and explained selection control structure and repetition control structure. Selection and repetition control structures increase the ability and power of a computer programs. Selection control structure allows a statement(s) to execute if a condition is true and another statement(s) executes if a condition is false. Repetition control structure or looping is the process of repeating execution of one or more steps of an algorithm or computer program. Essentially in programming, many performed calculations have repetitious tasks. Examples of both a selection control structure statement and a repetition control structure statement identifies and helps understand the importance of available computer operations to the programmer to compare variables, select one of two actions and repeat tasks as necessary. In programming the use of both selection and repetition control structure can reduce time for comparative statements and repeated conditions of tasks and provide computers with faster abilities to analyze and process data, which increases the usefulness and power of a computer program.

References
Conditions, Logical Expressions, and Selection Control Structures, Chapter 6 http://computerscience.jbpub.com/vbNet/pdfs/McMillan06.pdf
Robertson, Lesley Ann, Simple Program Design a step-by-step approach; http://instructor.mstc.edu/instructor/hkronhol/CourseInformation/152- 101ProLogicBeg/Unit5Decision/Robertson5ePP_Ch04_files/frame.htm www.thevbprogrammer.com; http://www.thevbprogrammer.com/Ch05/05-04- RepetitionStructure.htm

Similar Documents

Premium Essay

Get Online Help with Ur Assignment Ashford a+Material

...http://homeworktimes.com/downloads/acc-202-complete-course-acc-202-entire-course/ http://homeworktimes.com/downloads/acc-206-entire-course-new/ http://homeworktimes.com/downloads/acc-206-new-week-1-assignment-chapter-one-problems/ http://homeworktimes.com/downloads/acc-206-new-week-2-assignment-chapter-two-three-problems/ http://homeworktimes.com/downloads/acc-206-new-week-2-journal-institute-management-accounting/ http://homeworktimes.com/downloads/acc-206-new-week-3-assignment-chapter-four-five-problems/ http://homeworktimes.com/downloads/acc-206-new-week-3-journal-hershey-company/ http://homeworktimes.com/downloads/acc-206-new-week-4-assignment-chapter-six-seven-problems/ http://homeworktimes.com/downloads/acc-206-new-week-5-assignment-chapter-eight-problems/ http://homeworktimes.com/downloads/acc-206-new-week-5-assignment-final-paper/ http://homeworktimes.com/downloads/acc-212-financial-accounting/ http://homeworktimes.com/downloads/acc-250-complete-course-acc-205-entire-course/ http://homeworktimes.com/downloads/acc-290-complete-course-acc-290-entire-course/ http://homeworktimes.com/downloads/acc-291-complete-course-acc-290-entire-course/ http://homeworktimes.com/downloads/acc-340-entire-course-acc-340-complete-course/ http://homeworktimes.com/downloads/acc-400-complete-course-acc-400-entire-course/ http://homeworktimes.com/downloads/acc-407-entire-course/ http://homeworktimes.com/downloads/acc-455-complete-course/ http://homeworktimes.com/downl...

Words: 3197 - Pages: 13

Premium Essay

British Airway

...Airline Profits Rankings - Passenger services Rankings – Freight services Section 2 - British Airways Profile Overview Alliances LHR Air Transport Movements LGW Air Transport Movements Awards History Key Events (1987-2005) Board Members Leadership Team British Airways Management Team Employees Brands Departmental Analysis Section 3 - British Airways Fleet Aircraft Fleet Aircraft Delivery Schedule Mainline Fleet Profiles Regional Aircraft Fleet Maintenance Section 4 - British Airways Performance Summary Strategy Social and Environmental Performance Incentive Plans Summary Financial / Operating Statistics Principal Investments Shareholder Information Share Price History Section 5 - Global Partners Overview BA Connect Franchisees oneworld Aer Lingus American Airlines Cathay Pacific Finnair Iberia LanChile Qantas oneworld At A Glance Section 6 - Route Network British Airways Franchisees Section 7 - General Information Airport Three Letter Decodes Outside Advisors Abbreviations & Specialist Terms How To Contact Us 2 3 3 4 4 5 6 6 7 8 89 91 92 93 97 98 99 100 101 102 103 104 9 9 10 10 11 12 13 38 39 40 41 44 47 105 109 110 115 116 118 56 56 57 69 72 73 74 75 75 77 86 87 88 This document has been prepared solely for the purpose of providing information about British Airways to interested parties. It does not constitute an offer to sell any securities and must not be relied upon in connection with any investment decision. The information contained in the document...

Words: 59045 - Pages: 237

Free Essay

Avon in Global Market in 2009, Managing and Developing a Global Workforce

...The London School of Economics and Political Science THE ROLE OF CIVIL SOCIETY IN THE DEMOCRATISATION OF GLOBAL GOVERNANCE INSTITUTIONS: From ‘Soft Power’ to Collective Decision-Making? Saif Al-Islam Alqadhafi A thesis submitted to the Department of Philosophy of the London School of Economics for the degree of Doctor of Philosophy, London, September 2007 Declaration I certify that the thesis I have presented for examination for the MPhil/PhD degree of the London School of Economics and Political Science is solely my own work other than where I have clearly indicated that it is the work of others (in which case the extent of any work carried out jointly by me and any other person is clearly identified in it). The copyright of this thesis rests with the author. Quotation from it is permitted, provided that full acknowledgement is made. This thesis may not be reproduced without the prior written consent of the author. I warrant that this authorisation does not, to the best of my belief, infringe the rights of any third party. 2 Abstract This dissertation analyses the problem of how to create more just and democratic global governing institutions, exploring the approach of a more formal system of collective decision-making by the three main actors in global society: governments, civil society and the business sector. The thesis seeks to make a contribution by presenting for discussion an addition to the system of international governance that is morally...

Words: 127847 - Pages: 512

Free Essay

Social Strigication

...Department of Pediatrics and Adolescent Medicine, Tseung Kwan O Hospital, Hospital Authority). We would like to thank Mr. Gary Ip, the research assistant of the Department of Social Work and Social Administration, Ms. Garlum Lau, the senior research officer 2 of the Department of Sociology, the participants and NGOs for focus groups and case studies for their kind and valuable support on this project without which the completion of this study would not have been possible. 3 TABLE OF CONTENTS PREFACE ......................................................................................................................... 2 TABLE OF CONTENTS...................................................................................................... 4 EXECUTIVE SUMMARY...

Words: 80145 - Pages: 321

Premium Essay

Textbook

...This page intentionally left blank Introductory Econometrics for Finance SECOND EDITION This best-selling textbook addresses the need for an introduction to econometrics specifically written for finance students. It includes examples and case studies which finance students will recognise and relate to. This new edition builds on the successful data- and problem-driven approach of the first edition, giving students the skills to estimate and interpret models while developing an intuitive grasp of underlying theoretical concepts. Key features: ● Thoroughly revised and updated, including two new chapters on ● ● ● ● ● ● panel data and limited dependent variable models Problem-solving approach assumes no prior knowledge of econometrics emphasising intuition rather than formulae, giving students the skills and confidence to estimate and interpret models Detailed examples and case studies from finance show students how techniques are applied in real research Sample instructions and output from the popular computer package EViews enable students to implement models themselves and understand how to interpret results Gives advice on planning and executing a project in empirical finance, preparing students for using econometrics in practice Covers important modern topics such as time-series forecasting, volatility modelling, switching models and simulation methods Thoroughly class-tested in leading finance schools Chris Brooks is Professor of Finance at the ICMA Centre, University...

Words: 195008 - Pages: 781

Premium Essay

Econometrics

...This page intentionally left blank Introductory Econometrics for Finance SECOND EDITION This best-selling textbook addresses the need for an introduction to econometrics specifically written for finance students. It includes examples and case studies which finance students will recognise and relate to. This new edition builds on the successful data- and problem-driven approach of the first edition, giving students the skills to estimate and interpret models while developing an intuitive grasp of underlying theoretical concepts. Key features: ● Thoroughly revised and updated, including two new chapters on ● ● ● ● ● ● panel data and limited dependent variable models Problem-solving approach assumes no prior knowledge of econometrics emphasising intuition rather than formulae, giving students the skills and confidence to estimate and interpret models Detailed examples and case studies from finance show students how techniques are applied in real research Sample instructions and output from the popular computer package EViews enable students to implement models themselves and understand how to interpret results Gives advice on planning and executing a project in empirical finance, preparing students for using econometrics in practice Covers important modern topics such as time-series forecasting, volatility modelling, switching models and simulation methods Thoroughly class-tested in leading finance schools Chris Brooks is Professor of Finance...

Words: 195008 - Pages: 781

Premium Essay

Sanitation in Ghana

...REPUBLIC OF GHANA THE BUDGET STATEMENT AND ECONOMIC POLICY of the GOVERNMENT OF GHANA for the 2015 FINANCIAL YEAR presented to PARLIAMENT on WEDNESDAY, 19TH NOVEMBER 2014 by SETH E. TERKPER Minister for Finance on the Authority of HIS EXCELLENCY PRESIDENT JOHN DRAMANI MAHAMA Theme: “Transformational Agenda: Securing the Bright Medium Term Prospects of the Economy ’’ THE 2015 BUDGET STATEMENT AND ECONOMIC POLICY ~ ii ~ Theme: “Transformational Agenda: Securing the Bright Medium Term Prospects of the Economy ’’ For copies of the Statement, please contact the Public Relations Office of the Ministry: Ministry of Finance Public Relations Office New Building, Ground Floor, Room 001/003 P. O. Box MB 40 Accra – Ghana The 2015 Budget Statement and Economic Policy of the Government of Ghana is also available on the internet at: www.mofep.gov.gh ~ iii ~ Theme: “Transformational Agenda: Securing the Bright Medium Term Prospects of the Economy ’’ ACRONYMS AND ABBREVIATIONS ABFA ACLP ADR AFCON AfDB AIDS AML AMSECs APR ATMA AVIC BACs BDS BIEPC BoG BOP bopd bps BR BRICS BSPs BVDs Annual Budget Funding Amount Ascertainment and Codification of Customary Law Project Alternative Dispute Resolution African Cup of Nations African Development Bank Acquired Immune Deficiency Syndrome Anti-Money laundering Agricultural Mechanization Services Enterprise Centres Annual Progress Report Accra-Tema Metropolitan Area Accra Visitor Information Centre Business Advisory Centres...

Words: 63016 - Pages: 253

Premium Essay

Managing Cultura Differences

...MANAGING CULTURAL DIFFERENCES SIXTHEDITION MANAGING CULTURAL DIFFERENCES SERIES Managing Cultural Differences: Global Leadership Strategies for the 21 st Century, Sixth Edition Philip R. Harris, Ph.D., Robert T. Moran, Ph.D., Sarah V. Moran, M.A. Managing Cultural Diversity in Technical Professions Lionel Laroche, Ph.D Uniting North American Business—NAFTA Best Practices Jeffrey D. Abbot and Robert T. Moran, Ph.D. Eurodiversity: A Business Guide to Managing Differences George Simons, D.M. Global Strategic Planning: Cultural Perspectives for Profit and Non-Profit Organizations Marios I. Katsioulodes Ph.D. Competing Globally: Mastering Cross-Cultural Management and Negotiations Farid Elashmawi, Ph.D. Succeeding in Business in Eastern and Central Europe—A Guide to Cultures, Markets, and Practices Woodrow H. Sears, Ed.D. and Audrone Tamulionyte-Lentz, M.S. Intercultural Services: A Worldwide Buyer’s Guide and Sourcebook Gary M. Wederspahn, M.A. SIXTH EDITION MANAGING CULTURAL DIFFERENCES GLOBAL LEADERSHIP STRATEGIES ST FOR THE 21 CENTURY 25TH ANNIVERSARY EDITION PHILIP R. HARRIS, PH.D. ROBERT T. MORAN, PH.D. SARAH V. MORAN, M.A. JUDITH SOCCORSY Editorial Coordinator Elsevier Butterworth–Heinemann 200 Wheeler Road, Burlington, MA 01803, USA Linacre House, Jordan Hill, Oxford OX2 8DP, UK Copyright © 2004, Philip R. Harris, Robert T. Moran, Sarah V. Moran. All rights reserved. No part of this publication may be reproduced, stored in a...

Words: 229816 - Pages: 920