Lesson 6 - 1 Year 1 CS112/0401/V1 LESSON 6 DESIGN TOOL PSEUDOCODE  Program Design Language (PDL)  Represent logic in English-like manner  Easier to.

Slides:



Advertisements
Similar presentations
COMPUTER PROGRAMMING I Understand Problem Solving Tools to Design Programming Solutions.
Advertisements

Subject: Information Technology Grade: 10
Program Design Tool. 6 Basic Computer Operations Receive information Put out information Perform arithmetic Assign a value to variable (memory location)
 Control structures  Algorithm & flowchart  If statements  While statements.
1 Pseudocode For Program Design. 22 Rules for Pseudocode Write only one statement per line Capitalise initial keyword Indent to show hierarchy and structures.
ITEC113 Algorithms and Programming Techniques
Detailed Design Kenneth M. Anderson Lecture 21
Program Design and Development
Pseudocode and Algorithms
Repetition Control Structures
Chapter 2: Algorithm Discovery and Design
Chapter 2: Algorithm Discovery and Design
ALGORITHMS AND FLOWCHARTS
Fundamentals of Python: From First Programs Through Data Structures
Fundamentals of Python: First Programs
PROGRAMMING, ALGORITHMS AND FLOWCHARTS
Array Processing Simple Program Design Third Edition A Step-by-Step Approach 7.
Chapter 2: Algorithm Discovery and Design Invitation to Computer Science, C++ Version, Third Edition.
Designing and Debugging Batch and Interactive COBOL Programs Chapter 5.
Selection Control Structures. Simple Program Design, Fourth Edition Chapter 4 2 Objectives In this chapter you will be able to: Elaborate on the uses.
Conditions. Objectives  Understanding what altering the flow of control does on programs and being able to apply thee to design code  Look at why indentation.
BACS 287 Programming Logic 1. BACS 287 Programming Basics There are 3 general approaches to writing programs – Unstructured – Structured – Object-oriented.
1 Boolean Expressions to Make Comparisons Boolean expression –Represents only one of two states –Expression evaluates to either true or false Expressions.
Chapter 5: More on the Selection Structure Programming with Microsoft Visual Basic 2005, Third Edition.
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.
Flowcharts and Algorithms. Review of Terms  A computer is a machine that can represent and manipulate data –Ultimately the data and the instructions.
ALGORITHMS AND FLOWCHARTS CSCI 105 – Computer Fluency.
Lecture 2 Numerical Methods for Engineering MECN 3500 Department of Mechanical Engineering Inter American University of Puerto Rico Bayamon Campus Dr.
ITEC113 Algorithms and Programming Techniques
CONTENTS Processing structures and commands Control structures – Sequence Sequence – Selection Selection – Iteration Iteration Naming conventions – File.
Basic Control Structures
1 CISC181 Introduction to Computer Science Dr. McCoy Lecture 3 (2) & 4 September 8 & 10, 2009.
BACS 287 Programming Logic 2. BACS 287 Sequence Construct The sequence construct is the default execution mode for the CPU. The instructions are executed.
22/11/ Selection If selection construct.
1 Program Planning and Design Important stages before actual program is written.
Pseudocode An Introduction. Flowcharts were the first design tool to be widely used, but unfortunately they do not reflect some of the concepts of structured.
COIT29222 Structured Programming 1 COIT29222-Structured Programming Lecture Week 02  Reading: Textbook(4 th Ed.), Chapter 2 Textbook (6 th Ed.), Chapters.
Algorithm Discovery and Design Objectives: Interpret pseudocode Write pseudocode, using the three types of operations: * sequential (steps in order written)
Topics: Selection Statements. Processing Involving Selecting Instructions An instruction that allows deviation and selection to take place uses the ‘IF’
Algorithms and Pseudocode
STEP 3- DEVELOP AN ALGORITHM At this stage we break down the problem into simple manageable steps so that they can be handled easily.
Why Repetition? Read 8 real numbers and compute their average REAL X1, X2, X3, X4, X5, X6, X7, X8 REAL SUM, AVG READ *, X1, X2, X3, X4, X5, X6, X7, X8.
Pseudocode Skill Area Materials Prepared by Dhimas Ruswanto, BMm.
4 - Conditional Control Structures CHAPTER 4. Introduction A Program is usually not limited to a linear sequence of instructions. In real life, a programme.
Pseudocode. Algorithm A procedure for solving a problem in terms of the actions to be executed and the order in which those actions are to be executed.
Flow Charts And Pseudo Codes Grade 12. An algorithm is a complete step-by- step procedure for solving a problem or accomplishing a task.
 Problem Analysis  Coding  Debugging  Testing.
ALGORITHMS AND FLOWCHARTS
Understand Problem Solving Tools to Design Programming Solutions
Chapter 9 - Multimedia IDCS - Computer Technology.
3.1 Fundamentals of algorithms
GC211Data Structure Lecture2 Sara Alhajjam.
CS1001 Programming Fundamentals 3(3-0) Lecture 2
ALGORITHMS AND FLOWCHARTS
Designing and Debugging Batch and Interactive COBOL Programs
Pseudocode An Introduction
Unit# 9: Computer Program Development
Chapter 16 Component-Level Design
Algorithms & Pseudocode
Understanding the Three Basic Structures
Iteration: Beyond the Basic PERFORM
Iteration: Beyond the Basic PERFORM
ALGORITHMS AND FLOWCHARTS
Chapter 5: Control Structure
Boolean Expressions to Make Comparisons
Flowcharts and Pseudo Code
Pseudocode For Program Design.
REPETITION Why Repetition?
Introduction to Pseudocode
Presentation transcript:

Lesson Year 1 CS112/0401/V1 LESSON 6 DESIGN TOOL PSEUDOCODE  Program Design Language (PDL)  Represent logic in English-like manner  Easier to change

Lesson Year 1 CS112/0401/V1 Rules for Pseudocode  Language independent  Indentation for readability  Key words in capital letters  Punctuation optional  IF ends with ENDIF  Ends DO, DO WHILE, DO FOR with ENDDO  Main routine shown first

Lesson Year 1 CS112/0401/V1 Advantage of Pseudocode  Bridges gap between human language & computer language  Logic expressed in straightforward way  Easy to understand  Good design tool  Easier to make changes  Allow structured walkthroughs

Lesson Year 1 CS112/0401/V1 SEQUENCE/SELECTION

Lesson Year 1 CS112/0401/V1 SELECTION

Lesson Year 1 CS112/0401/V1 SELECTION (CASE)

Lesson Year 1 CS112/0401/V1 SELECTION (CASE) DO CASE CHOICE-A DO MOD-E ENDDO CHOICE-B DO MOD-F ENDDO CHOICE-C DO MOD-G ENDDO CHOICE-D DO MOD-H ENDDO ENDCASE

Lesson Year 1 CS112/0401/V1 ITERATION

Lesson Year 1 CS112/0401/V1 PSEUDOCODE  The three basic program constructs  Sequence  Selection  Iteration

Lesson Year 1 CS112/0401/V1 PSEUDOCODE  Sequence  A series of statements (instructions)  Pseudocode convention –READ –WRITE –ACCEPT –DISPLAY –PRINT –INPUT –GET  Consistent use of conventions throughout pseudocode

Lesson Year 1 CS112/0401/V1 PSEUDOCODE  Pseudocode convention Comments Statements that are non-executable Indication: /*…*/ e.g. /* Comment aids legibility */ e.g. /* This is an example of a long comment */

Lesson Year 1 CS112/0401/V1 PSEUDOCODE  Pseudocode Convention  Iteration: REPEAT…UNTIL To repeat a given set of commands Condition is checked after actions REPEAT commands UNTIL condition e.g. REPEAT ACCEPT number cube  number ** 3 DISPLAY number, cube UNTIL number = 0

Lesson Year 1 CS112/0401/V1 PSEUDOCODE  Pseudocode Convention  Do not use equal sign in assignment statements.  Use  in assignment statements or words ‘set to’  Use ‘=‘ sign only in conditional statements.

Lesson Year 1 CS112/0401/V1 PSEUDOCODE  Pseudocode Convention  Iteration: FOR loop For fixed number of iterations FOR index IN RANGE min TO max DO commands ENDDO e.g. FOR I IN RANGE 1 to 10 DO PRINT I, I**2 ENDDO

Lesson Year 1 CS112/0401/V1 PSEUDOCODE  Pseudocode Convention  Selection: IF…THEN Carry or ignore commands based on condition IF condition THEN commands ENDIF /* simple condition */ e.g. IF marks > 90 THEN class  ‘First’ ENDIF

Lesson Year 1 CS112/0401/V1 PSEUDOCODE /* compound condition */ e.g. IF marks >= 80 and marks <= 90 THEN class  ‘Second’ ENDIF

Lesson Year 1 CS112/0401/V1 PSEUDOCODE  Pseudocode Convention  IF-THEN-ELSE…ENDIF To select one of two or more alternative commands depending on a given condition IF condition THEN command sequence 1 ELSE command sequence 2 ENDIF e.g.IF marks >= 50 THEN remarks  ‘Pass’ ELSE remarks  ‘Fail’ ENDIF

Lesson Year 1 CS112/0401/V1 PSEUDOCODE  Pseudocode Convention  Multi-way selection Further extension of IF-THEN- ELSE construct to allow multiple selection IF condition 1 THEN command sequence 1 ELSE IF condition 2 THEN command sequence 2 ELSE IF condition 3 THEN command sequence 3 ENDIF (indentation for easy reading)

Lesson Year 1 CS112/0401/V1 PSEUDOCODE  Pseudocode Convention  Selection: Multi-way selection CASE…ENDCASE DO CASE of index CASE index condition 1 command sequence 1 CASE index condition 2 command sequence 2 CASE index condition 3 command sequence 3 OTHERWISE command sequence ENDCASE

Lesson Year 1 CS112/0401/V1 PSEUDOCODE  Pseudocode Convention  Selection: Multi-way / selection CASE…ENDCASE e.g. DO CASE OF menu_choice CASE ‘E’ DO enquiry routine ENDDO CASE ‘U’ DO update routine ENDDO CASE ‘X’ EXIT menu ENDDO OTHERWISE DISPLAY error message ENDCASE

Lesson Year 1 CS112/0401/V1 PSEUDOCODE Exercises 1.Write a pseudocode segment that reads 3 numbers A, B and C and display the biggest value of the three numbers.

Lesson Year 1 CS112/0401/V1 PSEUDOCODE Exercises 2. Write a pseudocode segment for a program that calculates the BONUS on a salesman’s sale. Zero if SALES is less than $2000 Ten percent of SALES if amount is between $2000 to $4000 Five percent of SALES plus $1000 if amount is $4000 or above