More on Psuedo-Code Sangeetha Parthasarathy 1/23/01.

Slides:



Advertisements
Similar presentations
State Machines An approach to assembler coding. Intro State Machines are an integral part of software programming. State machines make code more efficient,
Advertisements

CMSC 104, Version 9/011 The while Looping Structure Topics The while Loop Program Versatility o Sentinel Values and Priming Reads Checking User Input Using.
Reconfigurable Computing S. Reda, Brown University Reconfigurable Computing (EN2911X, Fall07) Lecture 07: Verilog (3/3) Prof. Sherief Reda Division of.
CS107 Introduction to Computer Science Lecture 3, 4 An Introduction to Algorithms: Loops.
UNIT 3 PROBLEM SOLVING WITH LOOP AND CASE LOGIC STRUCTURE
1 9/29/06CS150 Introduction to Computer Science 1 Loops Section Page 255.
Chapter 4 Repetitive Execution. 2 Types of Repetition There are two basic types of repetition: 1) Repetition controlled by a counter; The body of the.
1 9/29/06CS150 Introduction to Computer Science 1 Loops Section Page 255.
1 9/28/07CS150 Introduction to Computer Science 1 Loops section 5.2, 5.4, 5.7.
Switch structure Switch structure selects one from several alternatives depending on the value of the controlling expression. The controlling expression.
Control Structures: Part 2. Introduction Essentials of Counter-Controlled Repetition For / Next Repetition Structure Examples Using the For / Next Structure.
CS 280 Data Structures Professor John Peterson. Big O Notation We use a mathematical notation called “Big O” to talk about the performance of an algorithm.
Control Structures Control structures control the flow of program execution. 3 types of control structures: sequence, selection.
Section 3 - Selection and Repetition Constructs. Control Structures 1. Sequence 2. Selection 3. Repetition.
Functions. Program complexity the more complicated our programs get, the more difficult they are to develop and debug. It is easier to write short algorithms.
Fundamentals of Python: From First Programs Through Data Structures
Control Structures Week Introduction -Representation of the theory and principles of structured programming. Demonstration of for, while,do…whil.
Describe the Program Development Cycle. Program Development Cycle The program development cycle is a series of steps programmers use to build computer.
PHP Conditional Statements Conditional statements in PHP are used to perform different actions based on different conditions. Conditional Statements Very.
Coding Design Tools Rachel Gauci. What are Coding Design Tools? IPO charts (Input Process Output) Input- Make a list of what data is required (this generally.
Previously Repetition Structures While, Do-While, For.
Computer Science Department LOOPS. Computer Science Department Loops Loops Cause a section of your program to be repeated a certain number of times. The.
1 09/20/04CS150 Introduction to Computer Science 1 Let ’ s all Repeat Together.
An Introduction to Programming with C++ Sixth Edition Chapter 7 The Repetition Structure.
CIT 590 Intro to Programming Lecture 3. Pair programming logistics You and your partner submit 1 assignment Figure out who the submitter will be PLEASE.
Coding Design Tools Rachel Gauci. Task: Counting On Create a program that will print out a sequence of numbers from "1" to a "number entered”. Decision’s.
Lecture 4: Calculating by Iterating. The while Repetition Statement Repetition structure Programmer specifies an action to be repeated while some condition.
Pseudocode Algorithms Using Sequence, Selection, and Repetition
Chapter 3 - Structured Program Development Outline 3.1Introduction 3.2Algorithms 3.3Pseudocode 3.4Control Structures 3.5The If Selection Structure 3.6The.
Basic Control Structures
Structured Program Development Angela Chih-Wei Tang ( 唐 之 瑋 ) Department of Communication Engineering National Central University JhongLi, Taiwan 2010.
Advanced Computer Science Lesson 4: Reviewing Loops and Arrays Reading User Input.
Advanced Program Design. Review  Step 1: Problem analysis and specification –Specification description of the problem’s inputs and output –Analysis generalize.
Fundamentals of Algorithms MCS - 2 Lecture # 5. Representation of Algorithms (continued) Flowcharts.
GE 211 Dr. Ahmed Telba. // compound assignment operators #include using namespace std; int main () { a =5 int a, b=3; a = b; a+=2; // equivalent to a=a+2.
Subroutines II. An Extended Example Subroutines are best used to simplify large and unwieldy programs. Here is one example of why and how they should.
Algorithm Discovery and Design Objectives: Interpret pseudocode Write pseudocode, using the three types of operations: * sequential (steps in order written)
Think Possibility 1 Iterative Constructs ITERATION / LOOPS C provides three loop structures: the for-loop, the while-loop, and the do-while-loop. Each.
Clearly Visual Basic: Programming with Visual Basic 2008 Chapter 16 I’m on the Inside; You’re on the Outside.
Chapter 7: The Repetition Structure Introduction to Programming with C++ Fourth Edition.
CSCI/CMPE 4341 Topic: Programming in Python Chapter 4: Control Structures (Part 2) Xiang Lian The University of Texas – Pan American Edinburg, TX
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.
CMSC 104, Section 301, Fall Lecture 18, 11/11/02 Functions, Part 1 of 3 Topics Using Predefined Functions Programmer-Defined Functions Using Input.
Looping I (while statement). CSCE 1062 Outline  Looping/repetition construct  while statement (section 5.1)
Introduction to Computer Programming
Algorithm: procedure in terms of
while Repetition Structure
1-1 Logic and Syntax A computer program is a solution to a problem.
Think What will be the output?
Ch 7: JavaScript Control Statements I.
CMIS 102 Competitive Success-- snaptutorial.com
CMIS 102 Education for Service-- snaptutorial.com
CMIS 102 Teaching Effectively-- snaptutorial.com
The while Looping Structure
Java Fix a program that has if Online time for Monday’s Program
Algorithm An algorithm is a finite set of steps required to solve a problem. An algorithm must have following properties: Input: An algorithm must have.
Programming Right from the Start with Visual Basic .NET 1/e
Pseudocode algorithms using sequence, selection and repetition
Iteration: Beyond the Basic PERFORM
Loops CIS 40 – Introduction to Programming in Python
Algorithms Take a look at the worksheet. What do we already know, and what will we have to learn in this term?
The while Looping Structure
Repetition Structures
Java Fix a program that has if Online time for Monday’s Program
Let’s all Repeat Together
Chapter 4: Boolean Expressions, Making Decisions, and Disk Input and Output Prof. Salim Arfaoui.
Assignment #3 Programming Language, Spring 2003
The while Looping Structure
REPETITION Why Repetition?
Presentation transcript:

More on Psuedo-Code Sangeetha Parthasarathy 1/23/01

Modules Reusing work: Sometimes, one finds that an algorithm has to do same thing in different places. For example: To calculate average of the grades for students. One does not how many students in Advance, so we use an module that accepts the grades of number of students and finding their average. We could redefine the same set of statements of n of students, but that would be a repetition. If a change is to made in the statement, it would led to the problem of changing it certain places and forget to change in some places. This would led to algorithm in inconsistent state.

To avoid the above problems, one includes modules in psuedo- code. A module consists of three components: Input: Information that must be supplied to the module from outside. If module does need input from outside, then input is specified none. Process: A logic (specification) stating what the module does. Output: A result achieved due to processing performed in the module. The output is a value can be assigned to a variable. If module does not produce any value, then output is specified as none. If module returns a value, then there must be RETURN statement.

An Example of Module For example we might include to accept student number : Module: Name: getStudentNumber Input:None Output:studentNumber Process: PRINT(Please enter a student number) READ(studentNumber) RETURN(studentNumber)

Recursion Achieve Repetition in alternate way: You have seen in earlier sessions that repetition can be achieved by WHILE or FOR loops. However there is alternate to achieve repetition called recursion. Recursion is used in Modules that take at least one input. A recursive module always directly returns an output when some condition involving input(s) is true.