Pseudocode. Simple Program Design, Fourth Edition Chapter 2 2 Objectives In this chapter you will be able to: Introduce common words, keywords, and meaningful.

Slides:



Advertisements
Similar presentations
CS101: Introduction to Computer programming
Advertisements

Repetition Control Structures
CHAPTER 5: Repetition Control Structure. Objectives  To develop algorithms that use DOWHILE and REPEAT.. UNTIL structures  Introduce a pseudocode for.
PSEUDOCODE & FLOW CHART
Program Design Tool. 6 Basic Computer Operations Receive information Put out information Perform arithmetic Assign a value to variable (memory location)
ITEC113 Algorithms and Programming Techniques
Chapter 2: Algorithm Discovery and Design
Program Design and Development
Chapter 2 The Algorithmic Foundations of Computer Science
Chapter 8: Introduction to High-level Language Programming Invitation to Computer Science, C++ Version, Third Edition.
Pseudocode.
Chapter 1 Program Design
Chapter 8: Introduction to High-level Language Programming Invitation to Computer Science, C++ Version, Third Edition.
Pseudocode.
Chapter 3 Planning Your Solution
PRE-PROGRAMMING PHASE
Computer Science 101 Introduction to Programming.
DCT 1123 Problem Solving & Algorithms
CHAPTER 4: INTRODUCTION TO COMPUTER ORGANIZATION AND PROGRAMMING DESIGN Lec. Ghader Kurdi.
Pseudocode algorithms using sequence, selection and repetition
Simple Program Design Third Edition A Step-by-Step Approach
Array Processing Simple Program Design Third Edition A Step-by-Step Approach 7.
TMF1013 : Introduction To Computing Lecture 1 : Fundamental of Computer ComputerFoudamentals.
Chapter 3 Developing an algorithm. Objectives To introduce methods of analysing a problem and developing a solution To develop simple algorithms using.
Developing an Algorithm
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.
Chapter 8 High-Level Programming Languages. 8-2 Chapter Goals Describe the translation process and distinguish between assembly, compilation, interpretation,
Selection Control Structures. Simple Program Design, Fourth Edition Chapter 4 2 Objectives In this chapter you will be able to: Elaborate on the uses.
Developing an Algorithm
Selection Control Structure. Topics Review sequence control structure Structure theorem Selection control structure If statement Relational operators.
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.
An Introduction to Programming with C++ Sixth Edition Chapter 7 The Repetition Structure.
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.
Pseudocode Algorithms Using Sequence, Selection, and Repetition
Repetition Control Structures Simple Program Design Third Edition A Step-by-Step Approach 5.
Pseudocode Algorithms Using Sequence, Selection, and Repetition Simple Program Design Third Edition A Step-by-Step Approach 6.
First Steps in Modularization. Simple Program Design, Fourth Edition Chapter 8 2 Objectives In this chapter you will be able to: Introduce modularization.
Developing an Algorithm. Simple Program Design, Fourth Edition Chapter 3 2 Objectives In this chapter you will be able to: Introduce methods of analyzing.
Cosc175 - Define Problem/Design Solution/Pseudocode/Trace 1 DEFINE THE PROBLEM.
First Steps in Modularization. Simple Program Design, Fourth Edition Chapter 8 2 Objectives In this chapter you will be able to: Introduce modularization.
1 Program Planning and Design Important stages before actual program is written.
First Steps in Modularization. Simple Program Design, Fourth Edition Chapter 8 2 Objectives In this chapter you will be able to: Introduce modularization.
Fundamentals of Algorithms MCS - 2 Lecture # 5. Representation of Algorithms (continued) Flowcharts.
Algorithm Discovery and Design Objectives: Interpret pseudocode Write pseudocode, using the three types of operations: * sequential (steps in order written)
The Hashemite University Computer Engineering Department
Invitation to Computer Science 5 th Edition Chapter 2 The Algorithmic Foundations of Computer Science.
1 Overview of Programming Principles of Computers.
Chapter 7: The Repetition Structure Introduction to Programming with C++ Fourth Edition.
STEP 3- DEVELOP AN ALGORITHM At this stage we break down the problem into simple manageable steps so that they can be handled easily.
Lecture Notes 1/20/05 Pseudocode.  Pseudocode standard which we will follow in this class: - Statements are written in simple English; - Each instruction.
An Introduction to Programming with C++ Sixth Edition Chapter 5 The Selection Structure.
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.
1-1 Logic and Syntax A computer program is a solution to a problem.
Algorithm & Programming
PROGRAM CONTROL STRUCTURE
The Selection Structure
Introduction To Flowcharting
CHAPTER 2 & 3: Pseudocode and Developing and Algorithm
Program Design Introduction to Computer Programming By:
Pseudocode.
Programming Right from the Start with Visual Basic .NET 1/e
Pseudocode algorithms using sequence, selection and repetition
Lecture Notes 8/24/04 (part 2)
Chapter 8: More on the Repetition Structure
Click to add Text Computers & Instructions. Computers are given instructions in the form of computer programs that are created through the development.
Chapter 3: Selection Structures: Making Decisions
Introduction to Pseudocode
Presentation transcript:

Pseudocode

Simple Program Design, Fourth Edition Chapter 2 2 Objectives In this chapter you will be able to: Introduce common words, keywords, and meaningful names when writing pseudocode Define the three basic control structures as set out in the Structure Theorem Illustrate the three basic control structures using pseudocode

Simple Program Design, Fourth Edition Chapter 2 3 When designing a solution algorithm, you need to keep in mind that a computer will eventually perform the set of instructions written If you use words and phrases in the pseudocode which are in line with basic computer operations, the translation from pseudocode algorithm to a specific programming language becomes quite simple How to Write Pseudocode

Simple Program Design, Fourth Edition Chapter 2 4 Six Basic Computer Operations 1A computer can receive information –When a computer is required to receive information or input from a particular source, whether it is a terminal, a disk or any other device, the verbs Read and Get are used in pseudocode 2A computer can put out information –When a computer is required to supply information or output to a device, the verbs Print, Write, Put, Output, or Display are used in pseudocode –Usually an output Prompt instruction is required before an input Get instruction

Simple Program Design, Fourth Edition Chapter 2 5 Six Basic Computer Operations 3A computer can perform arithmetic –Most programs require the computer to perform some sort of mathematical calculation, or formula, and for these, a programmer may use either actual mathematical symbols or the words for those symbols –To be consistent with high-level programming languages, the following symbols can be written in pseudocode: + for Add- for Subtract for Multiply/ for Divide( ) for Parentheses –When writing mathematical calculations for the computer, standard mathematical ‘order of operations’ applies to pseudocode and most computer languages

Simple Program Design, Fourth Edition Chapter 2 6 Six Basic Computer Operations 4A computer can assign a value to a variable or memory location –There are three cases where you may write pseudocode to assign a value to a variable or memory location: 1.To give data an initial value in pseudocode, the verbs Initialize or Set are used 2.To assign a value as a result of some processing the symbols ‘=‘ or ‘  ’ are written 3.To keep a variable for later use, the verbs Save or Store are used

Simple Program Design, Fourth Edition Chapter 2 7 Six Basic Computer Operations 5A computer can compare two variables and select one or two alternate actions –An important computer operation available to the programmer is the ability to compare two variables and then, as a result of the comparison, select one of two alternate actions –To represent this operation in pseudocode, special keywords are used: IF, THEN, and ELSE

Simple Program Design, Fourth Edition Chapter 2 8 Six Basic Computer Operations 6A computer can repeat a group of actions –When there is a sequence of processing steps that need to be repeated, two special keywords, DOWHILE and ENDDO, are used in pseudocode –The condition for the repetition of a group of actions is established in the DOWHILE clause, and the actions to be repeated are listed beneath it

Simple Program Design, Fourth Edition Chapter 2 9 Meaningful Names All names should be meaningful A name given to a variable is simply a method of identifying a particular storage location in the computer The uniqueness of a name will differentiate it from other locations Often a name describes the type of data stored in a particular variable Most programming languages do not tolerate a space in a variable name, as a space would signal the end of the variable name and thus imply that there were two variables

Simple Program Design, Fourth Edition Chapter 2 10 The Structure Theorem The Structure Theorem states that it is possible to write any computer program by using only three basic control structures that are easily represented in pseudocode: –Sequence –Selection –Repetition

Simple Program Design, Fourth Edition Chapter 2 11 The Three Basic Control Structures 1Sequence –The sequence control structure is the straightforward execution of one processing step after another –In pseudocode, we represent this construct as a sequence of pseudocode statements 2Selection –The selection control structure is the presentation of a condition and the choice between two actions; the choice depends on whether the condition is true or false –In pseudocode, selection is represented by the keywords IF, THEN, ELSE, and ENDIF

Simple Program Design, Fourth Edition Chapter 2 12 The Three Basic Control Structures 3Repetition –The repetition control structure can be defined as the presentation of a set of instructions to be performed repeatedly, as long as a condition is true –The basic idea of repetitive code is that a block of statements is executed again and again, until a terminating condition occurs –This construct represents the sixth basic computer operation, namely to repeat a group of actions

Simple Program Design, Fourth Edition Chapter 2 13 Summary In this chapter, six basic computer operations were listed, along with pseudocode words and keywords to represent them These operations were: to receive information, put out information, perform arithmetic, assign a value to a variable, decide between two alternate actions, and repeat a group of actions The Structure Theorem was introduced; it states that it is possible to write any computer program by using only three basic control structures: sequence, selection, and repetition