The world of Constructs Control Structures. The three Structures Sequence Selection Loop Entry Exit.

Slides:



Advertisements
Similar presentations
Repetition Control Structures School of Business Eastern Illinois University © Abdou Illia, Spring 2003 (Week 9, Friday 3/07/2003)
Advertisements

Understanding the Three Basic Structures
ALGORITHMS THIRD YEAR BANHA UNIVERSITY FACULTY OF COMPUTERS AND INFORMATIC Lecture two Dr. Hamdy M. Mousa.
Flow Control if, while, do-while Juan Marquez (03_flow_control.ppt)
An Object-Oriented Approach to Programming Logic and Design
Pascal Programming Today Chapter 4 1 »Conditional statements allow the execution of one of a number of possible operations. »Conditional statements include:
Programming Logic and Design Seventh Edition
Control Structures 2 Chapter 6. © Janice Regan 2003 Basic Loops  When one action is to be repeated a number of times a loop is used. Loops are repetition.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Chapter 4 – C Program Control Outline 4.1Introduction.
C Lecture Notes 1 Program Control (Cont...). C Lecture Notes 2 4.8The do / while Repetition Structure The do / while repetition structure –Similar to.
Program Design and Development
© 2004 Pearson Addison-Wesley. All rights reserved5-1 Iterations/ Loops The while Statement Other Repetition Statements.
ECE122 L9: While loops March 1, 2007 ECE 122 Engineering Problem Solving with Java Lecture 9 While Loops.
4x + 2y = 18 a. (1,8) = 18 a. 4(1) + 2(8) = 18 b. (3,3)20 = 18 b. 4(3) + 2(3) = = = 18 15x + 5y = 5 a. (-2,7) NoYes b. (-1,4) a.
Lecture 4 C Program Control Acknowledgment The notes are adapted from those provided by Deitel & Associates, Inc. and Pearson Education Inc.
Java Programming: From Problem Analysis to Program Design, Second Edition1 Lecture 4 Objectives  Learn about repetition (looping) control structures.
Jaeki Song ISQS6337 JAVA Lecture 04 Control Structure - Selection, and Repetition -
Chapter 5 Control Structures: Loops 5.1 The while Loop The while loop is probably the most frequently used loop construct. The while loop is a conditional.
ENGR 112 Decision Structures.
Logic Structure - focus on looping Please use speaker notes for additional information!
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Flow Control (Switch, do-while, break) Outline 4.7The.
Programming Logic and Design Fifth Edition, Comprehensive
S2008Final_part1.ppt CS11 Introduction to Programming Final Exam Part 1 S A computer is a mechanical or electrical device which stores, retrieves,
CPS120 Introduction to Computer Programming The Programming Process.
Lecture 2: Logical Problems with Choices. Problem Solving Before writing a program Have a thorough understanding of the problem Carefully plan an approach.
Control Structures II Repetition (Loops). Why Is Repetition Needed? How can you solve the following problem: What is the sum of all the numbers from 1.
ITEC113 Algorithms and Programming Techniques
Saeed Ghanbartehrani Summer 2015 Lecture Notes #5: Programming Structures IE 212: Computational Methods for Industrial Engineering.
Chapter 3 - Structured Program Development Outline 3.1Introduction 3.2Algorithms 3.3Pseudocode 3.4Control Structures 3.5The If Selection Structure 3.6The.
Control Structures CPS120: Introduction to Computer Science Lecture 5.
Lecture 4: C/C++ Control Structures Computer Programming Control Structures Lecture No. 4.
Control Structures II: Repetition.  Learn about repetition (looping) control structures  Explore how to construct and use count-controlled, sentinel-controlled,
Computing with C# and the.NET Framework Chapter 3 Software Engineering with Control Structures.
CHAPTER 2: Understanding Structure. Objectives 2  Learn about the features of unstructured spaghetti code  Understand the three basic structures: sequence,
Copyright © 2010 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with Programming Logic & Design Second Edition by Tony Gaddis.
Programming Logic and Design, Introductory, Fourth Edition1 Understanding the Three Basic Structures Structure: a basic unit of programming logic Any program.
1 Lecture 2 Control Structures: Part 1 Selection: else / if and switch.
3.1.3 Program Flow control Structured programming – SELECTION in greater detail.
Programming Logic and Design Fifth Edition, Comprehensive
An Object-Oriented Approach to Programming Logic and Design Second Edition Chapter 2 Understanding Structure.
P ROGRAMMING L OGIC GWDA123 Sharon Kaitner, M.Ed. Winter 2015: Week 2.
Java Programming: From Problem Analysis to Program Design, 4e Chapter 5 Control Structures II: Repetition.
Java Programming: From Problem Analysis to Program Design, 3e Chapter 5 Control Structures II: Repetition.
Introduction to Programming G50PRO University of Nottingham Unit 6 : Control Flow Statements 2 Paul Tennent
Algorithm & Flow Charts Decision Making and Looping
C Program Control September 15, OBJECTIVES The essentials of counter-controlled repetition. To use the for and do...while repetition statements.
BIL 104E Introduction to Scientific and Engineering Computing Lecture 6.
Programming Logic and Design Fourth Edition, Introductory Chapter 2 Understanding Structure.
Loops causes program to execute the certain block of code repeatedly until some conditions are satisfied. Suppose you want to execute some code/s 10 times.
Lesson #4 Logical Operators and Selection Statements.
Lesson #4 Logical Operators and Selection Statements.
LOGICAL CONTROL STRUCTURES (chp. 8)
Topic 4: Looping Statements
Chapter 5: Control Structures II
Chapter 5: Control Structures II
Chapter 8 - JavaScript: Control Statements I
C# and the .NET Framework
CiS 260: App Dev I Chapter 4: Control Structures II.
Ch 7: JavaScript Control Statements I.
Programming Fundamentals
JavaScript: Control Statements I
Chapter 5: Control Structures II
CPS120: Introduction to Computer Science
STRUCTURED CONTROL: BASIC CONTROL OPERATORS
Understanding the Three Basic Structures
Chapter 8: More on the Repetition Structure
More Loops Topics Counter-Controlled (Definite) Repetition
More Loops Topics Counter-Controlled (Definite) Repetition
More Loops Topics Counter-Controlled (Definite) Repetition
Structural Program Development: If, If-Else
Presentation transcript:

The world of Constructs Control Structures

The three Structures Sequence Selection Loop Entry Exit

Sequence Control Structure The sequence control structure is used to show a single action or one action followed by another.

Flowchart & Pseudocode for sequence in a selection A? NoYes E D C B If A then do E Else do B do C do D

Selection Control Structure Conditio n FalseTrue Action 1 Action 2 One form of the selection control structure is the if-then-else, which is used to direct the program toward one course of action or another based on the evaluation of a condition.

Case Control Structure Condition Action 1Action 2Action 3Action 4 Condition 1Condition 2Condition 3Condition 4 The case allows for more than two alternatives when the condition is evaluated.

CLASS= “Freshman”? Fee = 75 Yes CLASS= “Soph”? Fee = 50 Yes No CLASS= “Junior”? Fee = 30 Yes No Fee = 10 If CLASS = “Freshman” FEE = 75 Else if CLASS = “Soph” FEE = 50 else if CLASS = “Junior” FEE=30 else FEE = 10

Do-While Control Structure Condition False True Action One form of the repetition control is the do-while, which tests the condition at the beginning of the loop.

Do-Until Control Structure Condition True False Action Another form of the repetition control structure is the do-until, which tests the condition at the end of the loop.

Nested Construct If-Then-Else Condition True False Action 1 Program modules often have control structures nested inside one another, each of which should have one entry point and one exit point. Do-While Condition True Action 1 False Do-While Entry point Do-While Exit point If-then-else Entry point If-then-else Exit point In this example, an if- then-else is nested inside a do-while.

Now it’s Your Turn Create a flowchart for number doubling program with sentinel value of zero Create a flowchart for number doubling program that uses EOF (End of File) as sentinel