1 Pseudocode For Program Design. 22 Rules for Pseudocode Write only one statement per line Capitalise initial keyword Indent to show hierarchy and structures.

Slides:



Advertisements
Similar presentations
Algorithms 10 IST – Topic 6.
Advertisements

More on Algorithms and Problem Solving
Microsoft® Small Basic
CHAPTER 5: Repetition Control Structure. Objectives  To develop algorithms that use DOWHILE and REPEAT.. UNTIL structures  Introduce a pseudocode for.
Understanding the Three Basic Structures
An Object-Oriented Approach to Programming Logic and Design
Computer Programming Rattapoom Waranusast Department of Electrical and Computer Engineering Faculty of Engineering, Naresuan University.
Programming Logic and Design Seventh Edition
Program Design Tool. 6 Basic Computer Operations Receive information Put out information Perform arithmetic Assign a value to variable (memory location)
Tutorial #6 PseudoCode (reprise)
Programming Logic and Design Seventh Edition
ITEC113 Algorithms and Programming Techniques
What is Pseudocode? Pseudocode is "halfway" between english and a programming language. It is a description of a process in detail, though not necessarily.
MATLAB Loops and Branching.
1 Chapter 2 Problem Solving Techniques INTRODUCTION 2.2 PROBLEM SOLVING 2.3 USING COMPUTERS IN PROBLEM SOLVING : THE SOFTWARE DEVELOPMENT METHOD.
Chapter 3 Planning Your Solution
1 Algorithm…. 2 Algorithm: Is a planned set of steps to solve certain problem Ex.: Assume for instance that the gross pay of an employee is to be calculated.
ALGORITHMS AND FLOWCHARTS
Adapted from slides by Marie desJardins
Python – Making Decisions Lecture 02. Control Structures A program that only has one flow is useful but limited. We can use if statements to make these.
Designing and Debugging Batch and Interactive COBOL Programs Chapter 5.
Iteration: WHILE Loop Damian Gordon. WHILE Loop Consider the problem of searching for an entry in a phone book with only SELECTION:
Presentation © Copyright 2002, Bryan Meyers Top-Down, Structured Program Design 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.
Chapter 2 Problem Solving On A Computer 2.1 Problem Solving Steps Solving a problem on a computer requires steps similar to those followed when solving.
Problem Solving Techniques. Compiler n Is a computer program whose purpose is to take a description of a desired program coded in a programming language.
BACS 287 Programming Logic 1. BACS 287 Programming Basics There are 3 general approaches to writing programs – Unstructured – Structured – Object-oriented.
Lesson Year 1 CS112/0401/V1 LESSON 6 DESIGN TOOL PSEUDOCODE  Program Design Language (PDL)  Represent logic in English-like manner  Easier to.
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.
ITEC113 Algorithms and Programming Techniques
CMSC 104: Peter Olsen, Fall 99Lecture 9:1 Algorithms III Representing Algorithms with pseudo-code.
Structured Programming Constructs March, 2011Copyright Yvette Francis.
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.
Component 4/Unit 5-3. Data Type Alphanumeric (Character set: A-Z, 0-9 and some special characters) –Customer address, name, phone number, Customer ID,
Programming Logic and Design, Introductory, Fourth Edition1 Understanding the Three Basic Structures Structure: a basic unit of programming logic Any program.
Prime Numbers Damian Gordon. Prime Numbers So let’s say we want to express the following algorithm: – Read in a number and check if it’s a prime number.
Topic: Control Statements. Recap of Sequence Control Structure Write a program that accepts the basic salary and allowance amount for an employee and.
Problem-solving with Computers. 2Outline  Computer System  5 Steps for producing a computer program  Structured program and programming  3 types of.
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.
Algorithms and Pseudocode
P ROGRAMMING L OGIC GWDA123 Sharon Kaitner, M.Ed. Winter 2015: Week 2.
Lecture Notes 1/20/05 Pseudocode.  Pseudocode standard which we will follow in this class: - Statements are written in simple English; - Each instruction.
Flow Control in Imperative Languages. Activity 1 What does the word: ‘Imperative’ mean? 5mins …having CONTROL and ORDER!
Fundamentals of Algorithms MCS - 2 Lecture # 3. Representation of Algorithms.
Program Program is a collection of instructions that will perform some task.
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.
Copyright © 2011 Pearson Education, Inc. Publishing as Prentice Hall Process Specifications and Structured Decisions Systems Analysis and Design, 8e Kendall.
Decision Tables and Pseudocode
Pseudocode An Introduction
Chapter 11 Describing Process Specifications and Structured Decisions
2008/09/22: Lecture 6 CMSC 104, Section 0101 John Y. Park
CS1001 Programming Fundamentals 3(3-0) Lecture 2
Pseudocode Upsorn Praphamontripong CS 1110 Introduction to Programming
Programming Fundamentals
ALGORITHMS AND FLOWCHARTS
Pseudocode An Introduction
Introduction to pseudocode
Algorithms & Pseudocode
Understanding the Three Basic Structures
ALGORITHMS AND FLOWCHARTS
ICT Programming Lesson 3:
The if Statement Control structure: logical design that controls order in which set of statements execute Sequence structure: set of statements that execute.
Data and Flowcharts Session
Flowcharts and Pseudo Code
Data and Flowcharts Session
UMBC CMSC 104 – Section 01, Fall 2016
If-Statements and If/Else Statements
Pseudocode For Program Design.
Presentation transcript:

1 Pseudocode For Program Design

22 Rules for Pseudocode Write only one statement per line Capitalise initial keyword Indent to show hierarchy and structures End multiline structures Keep statements language independent Remember you are describing a logic plan to develop a program, you are not programming!

33 One Statement Per Line Each statement in pseudocode should express just one action for the computer. Note capitals for the initial keywords These are just a few of the keywords to use, others include READ, WRITE, IF, ELSE, ENDIF, WHILE, ENDWHILE Pseudocode READ name, hoursWorked, payRate gross = hoursWorked * payRate WRITE name, hoursWorked, gross Pseudocode READ name, hoursWorked, payRate gross = hoursWorked * payRate WRITE name, hoursWorked, gross

44 Indent to Show Hierarchy Sequence: Keep statements in sequence all starting in the same column Selection: IF, ELSE (or ELSEIF), ENDIF must be in line Indent all statements that depend on a condition Loop: WHILE, ENDWHILE Indent statements that fall inside the loop but not keywords that form the loop Also REPEAT, UNTIL READ name, grossPay, taxes IF taxes > 0 net = grossPay – taxes ELSE net = grossPay ENDIF WRITE name, net READ name, grossPay, taxes IF taxes > 0 net = grossPay – taxes ELSE net = grossPay ENDIF WRITE name, net count = 0 WHILE count < 10 ADD 1 to count WRITE count ENDWHILE WRITE “The End” count = 0 WHILE count < 10 ADD 1 to count WRITE count ENDWHILE WRITE “The End”

55 The Looping Structure Pseudocode uses specific keywords to designate looping WHILE / ENDWHILE: condition checked before loop REPEAT / UNTIL: condition checked after loop

66 WHILE / ENDWHILE count = 0 WHILE count < 10 ADD 1 to count WRITE count ENDWHILE WRITE “The End” REPEAT / UNTIL count = 0 REPEAT ADD 1 to count WRITE count UNTIL count >= 10 WRITE “The End”

77 Multiple Decisions Example: the postage charged by Nation Couriers is Calculated on the weight of the parcel. < 2 kg$ – 5 kg$ $1 per kg over 2 kg > 5 kg$8 + $1 per kg over 5 kg READ weight CASE weight OF less than 2 : cost = $4.50 between 2 and 5 : cost = $ (weight – 2) greater than 5 : cost = $8 + (weight -5) END CASE PRINT cost