Flow of Control.

Slides:



Advertisements
Similar presentations
Control Structures.
Advertisements

Subprograms Functions Procedures. Subprograms A subprogram separates the performance of some task from the rest of the program. Benefits: “Divide and.
Programming Languages and Paradigms
Chapter 8 High-Level Programming Languages. 8-2 Chapter Goals Describe the translation process and distinguish between assembly, compilation, interpretation,
Chapter 2: Understanding Structure
CHAPTER 5: Repetition Control Structure. Objectives  To develop algorithms that use DOWHILE and REPEAT.. UNTIL structures  Introduce a pseudocode for.
Lecture 2 Basics of C#. Members of a Class A field is a variable of any type that is declared directly in a class. Fields are members of their containing.
A loop is a repetition control structure. it causes a single statement or block to be executed repeatedly What is a loop?
High-Level Programming Languages
Chapter 8 . Sequence Control
Chapter 8 High-Level Programming Languages Nell Dale John Lewis.
11/1/06 1 Hofstra University, CSC005 Chapter 8 (Part 3) High Level Programming Languages.
Week 11 Recap CSE 115 Spring Want to write a programming language? You’ll need three things: You’ll need three things: –Sequencing –Selection Polymorphism.
CS241 PASCAL I - Control Structures1 PASCAL I - Control Structures Philip Fees CS241.
Chapter 8 High-Level Programming Languages (modified by Erin Chambers)
INTRODUCTION TO PROGRAMMING STRUCTURE Chapter 4 1.
CIS Computer Programming Logic
Flow of Control. 2 Control Structures Control structure: An instruction that determines the order in which other instructions in a program are executed.
Chapter 8 High-Level Programming Languages. 8-2 Chapter Goals Describe the translation process and distinguish between assembly, compilation, interpretation,
ASP.NET Programming with C# and SQL Server First Edition Chapter 3 Using Functions, Methods, and Control Structures.
Chapter 4: Decision Making with Control Structures and Statements JavaScript - Introductory.
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.
CPS120 Introduction to Computer Science Iteration (Looping)
PL/SQL Loops. Building Logical Conditions All logical conditions must yield a boolean condition. You can build a simple Boolean condition by combining.
Chapter 8 High-Level Programming Languages. 8-2 Chapter Goals Describe the translation process and distinguish between assembly, compilation, interpretation,
Mr. Dave Clausen1 La Cañada High School Chapter 6: Repetition Statements.
6 Chapter 61 Looping Programming Logic and Design, Second Edition, Comprehensive 6.
CPS120: Introduction to Computer Science Decision Making in Programs.
CPS120: Introduction to Computer Science Functions.
ㅎㅎ logical operator if if else switch while do while for Third step for Learning C++ Programming Repetition Control Structures.
COMPUTER PROGRAMMING. Iteration structures (loops) There may be a situation when you need to execute a block of code several number of times. In general,
CPS120: Introduction to Computer Science Lecture 14 Functions.
CHAPTER 3 CONTROL STRUCTURES ( REPETITION ) I NTRODUCTION T O C OMPUTER P ROGRAMMING (CSC425)
Chapter 3 Functions, Events, and Control Structures JavaScript, Third Edition.
CMP-MX21: Lecture 5 Repetitions Steve Hordley. Overview 1. Repetition using the do-while construct 2. Repetition using the while construct 3. Repetition.
JavaScript, Fourth Edition
ITERATIVE STATEMENTS. Definition Iterative statements (loops) allow a set of instruction to be executed or performed several until condition are met.
8-1 Compilers Compiler A program that translates a high-level language program into machine code High-level languages provide a richer set of instructions.
Chapter 8 High-Level Programming Languages. 2 Chapter Goals Describe the translation process and distinguish between assembly, compilation, interpretation,
Chapter 15 JavaScript: Part III The Web Warrior Guide to Web Design Technologies.
CS241 PASCAL I - Control Structures1 PASCAL Control Structures Modified Slides of Philip Fees.
Looping ROBERT REVAES. Logical Operators  && AND  Both have to be true for it to evaluate to be true.  || OR  One or the other has to be true for.
1 For Loops l From Chapter 9 l A shorthand way of coding count loops.
Programming Fundamentals. The setw Manipulator setw changes the field width of output. The setw manipulator causes the number (or string) that follows.
Object-Oriented Program Development Using Java: A Class-Centered Approach, Enhanced Edition.
CS-1010 Dr. Mark L. Hornick 1 Selection and Iteration and conditional expressions.
Controlling Computers with Programs When you create a computer program you are creating a set of instructions that tell the computer exactly and completely.
Repetition Statements (Loops). 2 Introduction to Loops We all know that much of the work a computer does is repeated many times. When a program repeats.
Chapter 7: The Repetition Structure Introduction to Programming with C++ Fourth Edition.
Flow Control in Imperative Languages. Activity 1 What does the word: ‘Imperative’ mean? 5mins …having CONTROL and ORDER!
Looping Increment/Decrement Switch. Flow of Control Iteration/Switch Statements.
Conditional Statements A conditional statement lets us choose which statement will be executed next Conditional statements give us the power to make basic.
IST 210: PHP Logic IST 210: Organization of Data IST2101.
Computer Science 210 Computer Organization Machine Language Instructions: Control.
Follow up from lab See Magic8Ball.java Issues that you ran into.
Subprograms Functions Procedures.
Chapter 3: Decisions and Loops
Function There are two types of Function User Defined Function
Control Structures (Structured Programming) for controlling the procedural aspects of programming CS1110 – Kaminski.
Computer Science 210 Computer Organization
Chapter 8: More on the Repetition Structure
High Level Programming Languages
Low Level Programming Languages
CPS120: Introduction to Computer Science
Computer Science Core Concepts
ICT Gaming Lesson 3.
The structure of programming
Control Structures (Structured Programming) for controlling the procedural aspects of programming CS1110 – Kaminski.
The structure of programming
Thinking procedurally
Presentation transcript:

Flow of Control

Control Structures Control structure: An instruction that determines the order in which other instructions in a program are executed. Structured programming: A programming methodology in which each logical unit of a program should have just one entry and one exit.

Functionality of Imperative Languages Sequence - executing statements in sequence until an instruction is encountered that changes this sequencing Selection - deciding which action to take Iteration (looping) - repeating an action Subprogram - a named section of code which performs a specific task and is relatively independent of the remaining code.

Boolean Expressions Both selection and iteration require the use of a Boolean expression. Boolean expression A sequence of identifiers, separated by compatible operators, that evaluates to true or false. A Boolean expression can be A Boolean variable An arithmetic expression followed by a relational operator followed by an arithmetic expression A Boolean expression followed by a Boolean operator followed by a Boolean expression

Boolean Expressions Variable: A location in memory that is referenced by an identifier that contains a data value. Thus, a Boolean variable is a location in memory that can contain either true or false

Boolean Expressions A relational operator between two arithmetic expressions is asking if the relationship exists between the two expressions. For example, xValue < yValue, asks the question: “Is it true that xValue is less than yValue?”

Selection Statements The if statement allows the program to test the state of the program variables using a Boolean expression. It then selects one of two actions depending on the result of the test.

Selection Statements

Looping Statements There two distinct types of repetitions: Event-controlled loops The number of repetitions is controlled by an event that occurs within the body of the loop itself. Count-controlled loops Repeat a specified number of times Uses a special variable called a loop control variable

Looping Statements

Subprogram Statements We can give a section of code a name and use that name as a statement in another part of the program. When the name is encountered, the processing in the other part of the program halts while the named code is executed.

Subprogram Statements

Subprogram Statements There are times when the calling unit needs to give information to the subprogram to use in its processing. A parameter list is a list of the identifiers with which the subprogram is to work, along with the types of each identifier placed in parentheses beside the subprogram name.

Subprogram Statements

Subprogram Statements Parameters: Identifiers listed in parentheses beside the subprogram declaration; sometimes they are called formal parameters. Arguments: Identifiers listed in parentheses on the subprogram call; sometimes they are called actual parameters:

Subprogram Statements Value parameter: A parameter that expects a copy of its argument to be passed by the calling unit. Reference parameter: A parameter that expects the address of its argument to be passed by the calling unit.