Lecture Notes 1/20/05 Pseudocode.  Pseudocode standard which we will follow in this class: - Statements are written in simple English; - Each instruction.

Slides:



Advertisements
Similar presentations
CMSC 104, Version 9/011 Arithmetic Operators Topics Arithmetic Operators Operator Precedence Evaluating Arithmetic Expressions In-class Project Incremental.
Advertisements

Chapter 3: Modularization
Computer Programming Rattapoom Waranusast Department of Electrical and Computer Engineering Faculty of Engineering, Naresuan University.
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.
Foundation of programming Week 3. Last week ‘How to think like a programmer’ The HTTLAP 6 step approach: Understand the problem – Devise a plan to solve.
ITEC113 Algorithms and Programming Techniques
CS 1400 Course Reader Introduction. What is Programming? Designing an appropriate algorithm Coding that algorithm in a computer language.
TEL 104 / MKK Fundamental Programming: Lecture 3
Steps in Program Development
Program Design and Development
Lecture Notes 1/21/04 Program Design & Intro to Algorithms.
Pseudocode.
Lecture Notes 8/30/05 Program Design & Intro to Algorithms.
Pseudocode.
Chapter 3 Planning Your Solution
1 The First Step Learning objectives write Java programs that display text on the screen. distinguish between the eight built-in scalar types of Java;
Chapter 1 Pseudocode & Flowcharts
Chapter 1: An Introduction to Computers and Programming Prelude to Programming Concepts and Design Copyright © 2001 Scott/Jones, Inc.. All rights reserved.
DCT 1123 Problem Solving & Algorithms
© The McGraw-Hill Companies, 2006 Chapter 1 The first step.
Sw development1 Software Development 1.Define the problem (Analysis) 2.Plan the solution 3.Code 4.Test and debug 5.Maintain and Document.
PROGRAMMING, ALGORITHMS AND FLOWCHARTS
Pseudocode algorithms using sequence, selection and repetition
CPSC 171 Introduction to Computer Science 3 Levels of Understanding Algorithms More Algorithm Discovery and Design.
Hello World 2 What does all that mean?.
Introduction to Computational Linguistics Programming I.
Agenda  Commenting  Inputting Data from Keyboard (scanf)  Arithmetic Operators  ( ) * / + - %  Order of Operations  Mixing Different Numeric Data.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley STARTING OUT WITH Python Python First Edition by Tony Gaddis Chapter 2 Input,
Input, Output, and Processing
Arithmetic Operators Topics Arithmetic Operators Operator Precedence
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.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Extended Prelude to Programming Concepts & Design, 3/e by Stewart Venit and.
C++ Programming Language Lecture 2 Problem Analysis and Solution Representation By Ghada Al-Mashaqbeh The Hashemite University Computer Engineering Department.
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, Fourth Edition Chapter 2 2 Objectives In this chapter you will be able to: Introduce common words, keywords, and meaningful.
Pseudocode Simple Program Design Third Edition A Step-by-Step Approach 2.
Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley C H A P T E R 2 Input, Processing, and Output.
Flowcharts and Algorithms. Review of Terms  A computer is a machine that can represent and manipulate data –Ultimately the data and the instructions.
ITEC113 Algorithms and Programming Techniques
EXERCISES for ALGORITHMS WRITING
CHAPTER 1 INTRODUCTION 1 st Semester H King Saud University College Of Applied Studies and Community Services CSC 1101 Computer Programming-1.
Pseudocode Algorithms Using Sequence, Selection, and Repetition Simple Program Design Third Edition A Step-by-Step Approach 6.
CMSC 104: Peter Olsen, Fall 99Lecture 9:1 Algorithms III Representing Algorithms with pseudo-code.
Programming, an introduction to Pascal
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.
Assignment statement: Assigns a value to a variable Variable must appear on the left side, value on the right side of the assignment operator Right side.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Extended Prelude to Programming Concepts & Design, 3/e by Stewart Venit and.
CSC 1010 Programming for All Lecture 3 Useful Python Elements for Designing Programs Some material based on material from Marty Stepp, Instructor, University.
CMSC 104, Version 8/061L10ArithmeticOps.ppt Arithmetic Operators Topics Arithmetic Operators Operator Precedence Evaluating Arithmetic Expressions In-class.
© 2011 Pearson Addison-Wesley. All rights reserved. Addison Wesley is an imprint of Stewart Venit ~ Elizabeth Drake An Introduction to Programming.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley STARTING OUT WITH Python Python First Edition by Tony Gaddis Chapter 2 Input,
The Hashemite University Computer Engineering Department
Algorithms and Pseudocode
CS 101 – Oct. 7 Solving simple problems: create algorithm Structure of solution –Sequence of steps (1,2,3….) –Sometimes we need to make a choice –Sometimes.
Chapter 1 Introduction 2nd Semester H
ALGORITHMS AND FLOWCHARTS
Introduction To Flowcharting
Starter Write a program that asks the user if it is raining today.
Each instruction on a separate line
CHAPTER 2 & 3: Pseudocode and Developing and Algorithm
Pseudocode.
Pseudocode algorithms using sequence, selection and repetition
Lecture Notes 8/24/04 (part 2)
Introduction to Algorithms and Programming
King Saud University College Of Applied Studies and Community Services CSC 1101 Computer Programming-1 Done By: Asmal Alosaimi Edited By: Fatimah Alakeel.
King Saud University College Of Applied Studies and Community Services CSC 1101 Computer Programming-1 Done By: Asmal Alosaimi Edited By: Fatimah Alakeel.
Pseudocode For Program Design.
Introduction to Pseudocode
Presentation transcript:

Lecture Notes 1/20/05 Pseudocode

 Pseudocode standard which we will follow in this class: - Statements are written in simple English; - Each instruction is written on a separate line; - Each set of instructions is written from top to bottom, with only one entry and one exit; - Groups of statements may be formed into modules, and that group given a name.

How to Write Pseudocode 6 basic computer operations:  receive information  put out information  perform arithmetic  assign a value to a variable or memory location  compare two variables and select one of two alternative actions  repeat a group of actions

Receive Information A computer generally gets information in one of the following ways:  From a file  Pseudocode -> “Read”  From a keyboard  Pseudocode -> “Get”

Receive Information Examples:  Get file name  Read first line from the file  Get number of students  Read the names of the students from the file

Put Out Information A computer generally outputs information in one of the three ways:  Print on a printer  “Print”  Write to a file  “Write”  Display on a monitor  “Display”

Put Out Information Examples:  Print “Hello everyone!”  Write “My first homework” to hw_1.txt  Display average_age

Perform Arithmetic Either actual mathematical symbols or words can be used:  Multiply Length by Width to compute Area  Area = Length * Width

Perform Arithmetic Symbols that will be used in this class: Addition + Subtraction - Division/ Multiplication* Modulus% Parentheses () Also can use the words : Compute and Calculate

Example Write the pseudocode for calculating the average age of the students in our class. Prompt the user for number of students Get number of students Prompt for all of the ages Get the ages of all students Add all ages together to obtain Total_Age Divide Total_Age by the number of students Display the result

Compare Two Variables and Select One of Two Actions Examples:  If it starts to rain, I’ll go inside the building.  If the car starts, I’ll drive. Otherwise I’ll take a bus.  If you are tall enough, you can go on this ride. Otherwise, you have to wait till next year. Special keywords IF, THEN, ELSE, ENDIF

Compare Two Variables and Select One of Two Actions Example: IF Age > 0 THEN Add 1 to number_students ELSE Display “Age must be positive” ENDIF

Repeat a Group of Actions Examples:  Shake the vending machine until the candy bar falls down.  Wash your hands until they are clean. Special keywords: WHILE and ENDWHILE

Repeat a Group of Actions Example: set Total_Age and Age to zero set number_students to 0 WHILE number_students < 60 get next student’s age and store it in AGE Total_Age = Total_Age + Age add 1 to number_students ENDWHILE display Total_Age

Homework for Tuesday  Picture.  Provide the defining diagram, solution algorithm and a desk check for a problem (find in online).  Read Chapter 2 in “C++ Programming”.