This website uses cookies to ensure you have the best experience. Learn more

Selection And Repetition Control Structures Essay

546 words - 3 pages

Selection and Repetition Control Structures

Selection Control Structures

When a programmer is writing a program that needs to choose between two or more actions dependent upon whether the condition is true or false, a selection control structure is used. Relational operators such as less than (<), greater than (>) and equal to (< >, =) are used to express the conditions. The addition of selection control structures to a program gives a program more structure and the programmer has more flexibility in program construction.
There are four kinds of selection control structures:
1. Simple selection
2. Simple selection with null force branch
3. Combined selection
4. Nested selection
Suppose a programmer wants to process the results of a survey on how many people in San ...view middle of the document...

They are also known as iteration control structures.
There are three repetition control structures and where the decision to repeat a statement is placed determines which one of the control structures is used:
1. Leading decision loop or DOWHILE loop is used at the beginning of the loop.
2. Trailing decision loop or REPEAT…UNTIL loop is used at the end of the loop.
3. Counted repetition loops, also called DO or FOR loops are used when the number of loop iterations to repeat is known in advance.
The following is an example of a counted repetition loop to convert miles per hour to kilometers per hour. The following conversion is based on Robertson (n.d.):
Miles-per-Hour_Kilometers-per-Hour_Conversion
1. DO mph_count = 5 to 13
2. prompt operator for mph
3. Get mph
4. compute kph = (mph * 1.6)
5. Display kph
ENDDO
6. Display ‘All speeds processed’ to the screen

The DO loop controls the repetition by:
* initializing the mph to 5
* increments the mph by 5 for each pass through the loop
* tests mph at the beginning of each pass to ensure it is within the 5 to 13 range
* automatically terminates the loop once the mph exceeds 13

References
Robertson, L. A. (n.d.). Simple program design: A step by step approach. [University of Phoenix
Custom Edition e-Text]. Mason, Ohio: Cengage Learning. Retrieved from Axia College, PRG210 - Fundamentals of Programming website.

Other Papers Like Selection and Repetition Control Structures

Decentralization Essay

574 words - 3 pages Selection Control Structures/Repetition Control Structures Statement of Purpose Personal Statement Academic and Professional Goals Statement statement of interest Personal Statement - PHD in Leadership Related searches on Advanced Management Journal, CFO, CSCW statement courseworks sample studies on more papers on organisations Swedish Social Insurance Board analysis merits of more disadvantages of Strathclyde Business School advantages and disadvantages of more organisations summary cause and effect of Swedish Social Insurance Board statement fallacies CFO test advantages of Swedish Social Insurance Board organisations introduction .

Programming Solution Proposal Essay

656 words - 3 pages structured control flow that is standard in programming, which includes sequence, selection and repetition. When developing programs, it is essential to follow the structure guidelines in order to avoid winding up with a block of spaghetti code, or code that jumps around haphazardly within the program skipping important steps, not addressing all possible input conditions and a host of other program-breaking issues. Keeping in line with top-down

Principles of Management

966 words - 4 pages Real Number Output Lecture with Blackboard Handouts Assignment Recitation permanently assigned values. How new values of various types can be generated by the use of operators Declaration, Constant and Enumeration  Where to put constant, variable and declarations Assignment and Expression Program Control Structures  Sequence Structures  Selection Structures Hands-On Exercises Multimedia Presentation Seatwork Quizzes

Memory, Learning, and Perception

1636 words - 7 pages stimulus that elicits a response is paired with another stimulus that initially does not elicit a response on its own (Pavlov) What happens when it’s time for class to be over??? Uses of Classical Conditioning Brand names and brand associations to create brand equity = strong positive association Product line extensions - positive carryover Repetition of a message, frequency marketing Generalization through look-alike products

The Neuroanatomical, Neurophysiological and Neuropsychological Aspects of Obsessive Compulsive Disorder

2068 words - 9 pages attribute this to “deficient inhibitory control on motor output from subcortical structures, such as basal ganglia and thalamus”. The study conducted by Viswanath et al. (2009) observed than non-OCD siblings of patients with OCD had impairments in decision making and behavioral reversal, which they concluded was consistent with a model of OCD involving the orbitofrontal circuit. Furthermore Biju et al. (2009) state that the difficulties in

"On Being a Cripple" Essay

790 words - 4 pages In this excerpt from On Being a Cripple, Nancy Mairs’s courageous tone combined with her self-acceptance depicts the troubles of language utilized in present times in order to describe a person with a serious imperfection. Mairs discusses her straightforward title, a cripple, in order to explore the real meaning of being an individual and the voyage of accepting who you truly are. With the use of strong word choice, rhetorical structures

Organic And Mechanistic

2351 words - 10 pages many procedural rules, knowledge of work and monitoring of the task centralized on the top of organisation (Taylor, 1911), emphasized the vertical communications of superior to subordinate, through the classical theorist (Fayol, 1949) and “top-down” control established by management information system (MIS) to coordination and control tend to adopt rigorous hierarchical organizational structures (such as structure of production department). The

Ict Notes

1465 words - 6 pages ],Age[2],Age[3] * 3 basic structures used to build a program. * Sequence : used when program statements are followed one after the other. * Selection: (decision) when a choice is made by the user. Based on some criterion. Example: If statement * Iteration (repetition) when a section of code is repeated using a loop. * Note: Always True or False Note: Always True or False If statements are used to check for a condition

Introduction to Design

4272 words - 18 pages best ones to explain. This is an archive of free texture for use in 3D animation. This is the collection of dry leaves. We can always find this in our environment. When we think of creating our own work of art there are so many things to consider: the support or surface, subject matter, background, light source, center of interest, and so forth. We know what makes up a good overall design: color management, value, and intensity control

Afdsfdsaf

1354 words - 6 pages 1. A program can be made of only one type of control structure. You cannot combine structures. 2. A single alternative decision structure tests a condition and then takes one path if the condition is true, or another path if the condition is false. 3. A decision structure can be nested inside another decision structure. 4. A compound Boolean expression created with the AND operator is true only when both sub-expressions are true

Strategic Human Resource Management

2585 words - 11 pages layoffs and provide new openings. Encourage mobility as reorganizations shift jobs around. | Plan and implement workforce reductions and reallocations of duties and responsibilities. | Compensation and Training | Meet or exceed labour market needs to attract market talent. | Meet external market but consider internal equity effects. Establish formal compensation structures. | Control Compensation | Tighter cost control. | Employee Training

Related Essays

Prg 210 Week 4 Paper

1301 words - 6 pages 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

Lalalallalala Essay

1423 words - 6 pages C H A P T E R 1.4 Structured Programming CHAPTER OUTLINE DECISION/SELECTION STRUCTURES REPETITION STRUCTURES INTRODUCTION Chapter Objectives At the end of the chapter, the student should be able to:  understand how different program structure works;  learn how to write algorithms using program structures; and  evaluate algorithms which contain program structures. 2 DECISION/SELECTION STRUCTURES If-Then Statements A

Prg Week 3 Dq2 Essay

571 words - 3 pages WEEK 3 DQ 2 PRG 211 * What are the similarities and differences between single alternative structures, dual alternative structures, and case structures? Provide an example of one of the three control structures using pseudocode. Try to provide an example that has not already been posted. Selection structures ask a question and, depending on the answer, take one of two courses of action. Then, no matter which path is followed, they

Computer Science Essay

4919 words - 20 pages instructions. Lego NXT uses special blocks and Java uses for and while keywords for repetition. Repetition is also called looping or the more formal term iteration. In this chapter you will learn that there are more ways to control program execution besides repetition. Program-execution-flow is controlled by three general types of control structures. They are simple sequence, repetition, and selection. Lego NXT provides program blocks for