Nassi-Schneidermann Diagrams Lecture 13. Three basic control Structures.

Slides:



Advertisements
Similar presentations
Repetition There are three different ways that a set of instructions can be repeated, and each way is determined by where the decision to repeat is.
Advertisements

Repetition Control Structures
Understanding the Three Basic Structures
Program Design Tool. 6 Basic Computer Operations Receive information Put out information Perform arithmetic Assign a value to variable (memory location)
Selection control structures
Repetition Control Structure
TEL 104 / MKK Fundamental Programming: Lecture 3
 2002 Prentice Hall. All rights reserved. 1 Outline 4.1 Introduction 4.2 Algorithms 4.3 Pseudocode 4.4 Control Structures 4.5 The if Selection Structure.
Steps in Program Development
1 TEL 104 / MKK Fundamental Programming: Lecture 4.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Chapter 3 - Structured Program Development Outline.
Program Design and Development
Array Processing Lecture 7.
COMP 14 Introduction to Programming Miguel A. Otaduy May 20, 2004.
Repetition Control Structures
Pseudocode.
Pseudocode Algorithms Using Sequence, Selection, and Repetition.
 2003 Prentice Hall, Inc. All rights reserved. 1 Outline 4.1 Introduction 4.2 Algorithms 4.3 Pseudocode 4.4 Control Structures 4.5 if Single-Selection.
Structured Program Development in C
Engineering H192 - Computer Programming The Ohio State University Gateway Engineering Education Coalition Lect 3P. 1Winter Quarter Structured Engineering.
1 Chapter 4 Simple Selections and Repetitions INTRODUCTION The majority of challenging and interesting algorithms necessitate the ability to make.
COMP 110 Introduction to Programming Mr. Joshua Stough September 24, 2007.
Pseudocode.
Engineering H192 - Computer Programming The Ohio State University Gateway Engineering Education Coalition Lect 3P. 1Winter Quarter Structured Engineering.
CONTROL STATEMENTS Lakhbir Singh(Lect.IT) S.R.S.G.P.C.G. Ludhiana.
DCT 1123 Problem Solving & Algorithms
Presented by Joaquin Vila Prepared by Sally Scott ACS 168 Problem Solving Using the Computer Week 12 Boolean Expressions, Switches, For-Loops Chapter 7.
Combination of Sequence, Selection and Repetition
DCT 1123 Problem Solving & Algorithms
Array Processing Simple Program Design Third Edition A Step-by-Step Approach 7.
Programming in Java (COP 2250) Lecture 11 Chengyong Yang Fall, 2005.
Selection Control Structures Simple Program Design Third Edition A Step-by-Step Approach 4.
Chapter 7 Array processing. Objectives To introduce arrays and the uses of arrays To develop pseudocode algorithms for common operations on arrays To.
Array Processing.
Selection Control Structures. Simple Program Design, Fourth Edition Chapter 4 2 Objectives In this chapter you will be able to: Elaborate on the uses.
Mr. Dave Clausen1 La Cañada High School Chapter 6: Repetition Statements.
Chapter 2 Pseudocode. Objectives To introduce common words, keywords and meaningful names when writing pseudocode To define the three basic control structures.
Pseudocode Simple Program Design Third Edition A Step-by-Step Approach 2.
 2003 Prentice Hall, Inc. All rights reserved. 1 Chapter 4 - Control Structures: Part 1.
1 Outline 4.1 Introduction 4.2 Algorithms 4.3 Pseudocode 4.4 Control Structures 4.5 The if Selection Structure 4.6 The if / else Selection Structure 4.7.
Pseudocode Algorithms Using Sequence, Selection, and Repetition
 2008 Pearson Education, Inc. All rights reserved JavaScript: Control Statements I.
Lecture 2 Control Structure. Relational Operators -- From the previous lecture Relational Operator Meaning == is equal to < is less than > is greater.
The world of Constructs Control Structures. The three Structures Sequence Selection Loop Entry Exit.
 2003 Prentice Hall, Inc. All rights reserved. 1 Outline 4.1 Introduction 4.2 Algorithms 4.3 Pseudocode 4.4 Control Structures 4.5 if Single-Selection.
Pseudocode Algorithms Using Sequence, Selection, and Repetition Simple Program Design Third Edition A Step-by-Step Approach 6.
Engineering H192 - Computer Programming Gateway Engineering Education Coalition Lect 3P. 1Winter Quarter Structured Engineering Problem Solving and Logic.
Control Structures RepetitionorIterationorLooping Part I.
Control Structures RepetitionorIterationorLooping Part I.
Flowcharts. Symbol Terminal Symbol: indicates the starting or stopping pointin the logic. Input/Output Symbol: Represents an input or output process in.
Flowcharts Lecture 12.
 2003 Prentice Hall, Inc. All rights reserved. 1 Will not cover 4.14, Thinking About Objects: Identifying Class Attributes Chapter 4 - Control Structures.
1 COMS 261 Computer Science I Title: C++ Fundamentals Date: September 23, 2005 Lecture Number: 11.
C++ Programming: CS150 For.
Intro to Programming Week # 6 Repetition Structure Lecture # 10
JavaScript: Control Statements I
Control Statements Kingdom of Saudi Arabia
Topics discussed in this section:
CHAPTER 2 & 3: Pseudocode and Developing and Algorithm
Pseudocode.
Structured Program
Chapter 3 - Structured Program Development
Lecture Notes 8/24/04 (part 2)
3 Control Statements:.
Chapter 3 – Control Structures
Chapter 3 - Structured Program Development
Chapter 4 - Control Structures: Part 1
EPSII 59:006 Spring 2004.
REPETITION Why Repetition?
Introduction to Pseudocode
Presentation transcript:

Nassi-Schneidermann Diagrams Lecture 13

Three basic control Structures

Sequence Statement a Statement b Statement c

Selection IF condition p true yes no Statement aStatement b

Repetition DOWHILE condition p is true Statement block

Repetition DOWHILE condition p is true Statement block

Example 13.1  A program is required to read three numbers, add them together and print their total.

N-S Diagram and the selection control structure

Simple IF Statement IF account_balance < $ 300 Yes No Service_charge = $ 5Service_charge = $ 2

Null ELSE Statement IF student_attendance = part_time Yes No Add 1 to part_time_count

Combined IF Statement IF student_attendance = part_time AND Student_gender = female Yes No Add 1 to female_part_time_count

NESTED IF STATEMENT

A. Linear nested IF statement IF record_code = ´A´ IF record_code = ´B´ IF record_code = ´C´ Yes No Increment counter_A Increment counter_B Increment counter_C Increment error_counter

B. Non-linear nested IF statement IF student_attendance = part_time Yes No IF Student_gender = female IF student_age > 21 Add 1 to mature_female_ pt_students Add 1 to young_female_ pt_students Add 1 to male_ pt_students Add 1 to full_time_students

N-S Diagram and Case Structure CASE OF single variable Value 1 Value 2Value 3Value 4 Statement block_1 Statement block_2 Statement block_n Statement block_other

N-S Diagram and the repetition control structure DOWHILE condition p is true Statement block

Assignment1. Print Examination Scores A program is required to read and print a series of names and exam scores for students enrolled in a mathematic course. The class average is to be computed and printed at the end of the report. Scores can range from 0 to 100. The last record contains a blank name and a score of 999 and is not to be included in the calculations.

Assignment2. Process Inventory Items A program is required to read a series of inventory records that contain item number, item description and stock figure. The last record in the file has an item number of zero. The program is to produce a low stock item report, by printing only those records that have a stock figure of less than 20 items. A heading is to be printed at the top of the report and a total low stock item count printed at the end.