PSEUDOCODE C Programming Technique – Firdaus-Harun.com.

Slides:



Advertisements
Similar presentations
C Programming Technique – Firdaus-Harun.com
Advertisements

ALGORITHMS AND FLOWCHARTS
PROBLEM SOLVING TECHNIQUES
Flow Control Analysis & Design Tool: Flowcharts
UNIT 2. Introduction to Computer Programming
Chapter 2- Visual Basic Schneider1 Chapter 2 Problem Solving.
ALGORITHMS AND FLOWCHARTS
 Control structures  Algorithm & flowchart  If statements  While statements.
Chapter 2- Visual Basic Schneider
 2002 Prentice Hall. All rights reserved. 1 Outline 4.1 Introduction 4.2 Algorithms 4.3 Pseudocode 4.4 Control Structures 4.5 The if Selection Structure.
Chapter 3 - Structured Program Development
Introduction to Computers and Programming Lecture 5 New York University.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Chapter 3 - Structured Program Development Outline.
Introduction to Computers and Programming Lecture 8: More Loops New York University.
1 Outline 4.1 Introduction 4.2 Algorithms 4.3 Pseudocode 4.4 Control Structures 4.5 if Single-Selection Statement 4.6 if else Selection Statement 4.7 while.
 2000 Prentice Hall, Inc. All rights reserved. Chapter 3 - Structured Program Development Outline 3.1Introduction 3.2Algorithms 3.3Pseudocode 3.4Control.
Developing logic (Examples on algorithm and flowchart)
Structured Program Development in C
Lecture 3 Structured Program Development in C
 2002 Prentice Hall. All rights reserved. 1 Chapter 3 – Control Structures Outline 3.1 Introduction 3.2 Algorithms 3.3 Pseudocode 3.4Control Structures.
The Program Design Phases
ALGORITHMS AND FLOWCHARTS
The University of Texas – Pan American
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Structural Program Development: If, If-Else Outline.
Structured Program Development Outline 2.1Introduction 2.2Algorithms 2.3Pseudo code 2.4Control Structures 2.5The If Selection Structure 2.6The If/Else.
C Lecture Notes 1 Structured Program Development.
Chapter 3 - Structured Program Development Outline 3.1Introduction 3.2Algorithms 3.3Pseudocode 3.4Control Structures 3.5The If Selection Structure 3.6The.
 2000 Prentice Hall, Inc. All rights reserved. 1 Chapter 3 - Structured Program Development Outline 3.1Introduction 3.2Algorithms 3.3Pseudocode 3.4Control.
ALGORITHMS AND FLOWCHARTS CSCI 105 – Computer Fluency.
 2003 Prentice Hall, Inc. All rights reserved. 1 Chapter 4 - Control Structures: Part 1.
1 Outline 4.1 Introduction 4.2 Algorithms 4.3 Pseudocode 4.4 Control Structures 4.5 The if Selection Structure 4.6 The if / else Selection Structure 4.7.
 2003 Prentice Hall, Inc. All rights reserved. 1 Control Structures Outline -Introduction -Algorithms -Pseudocode -Control Structures -if Selection Structure.
C Programming 2002 Chapter 3 - Structured Program Development Outline 3.1Introduction 3.2Algorithms 3.3Pseudocode 3.4Control Structures 3.5The If Selection.
Chapter 3 - Structured Program Development Outline 3.1Introduction 3.2Algorithms 3.3Pseudocode 3.4Control Structures 3.5The If Selection Structure 3.6The.
 2008 Pearson Education, Inc. All rights reserved JavaScript: Control Statements I.
 2003 Prentice Hall, Inc. All rights reserved. 1 Outline 4.1 Introduction 4.2 Algorithms 4.3 Pseudocode 4.4 Control Structures 4.5 if Single-Selection.
Structured Program Development Angela Chih-Wei Tang ( 唐 之 瑋 ) Department of Communication Engineering National Central University JhongLi, Taiwan 2010.
1. Understand the application of Pseudo Code for programming purposes 2. Be able to write algorithms in Pseudo Code.
1 Lecture 3 Control Structures else/if and while.
1 Program Planning and Design Important stages before actual program is written.
Lecture 5: Stopping with a Sentinel. Using a Sentinel Problem Develop a class-averaging program that will process an arbitrary number of grades each time.
Chapter 3 Structured Program Development Associate Prof. Yuh-Shyan Chen Dept. of Computer Science and Information Engineering National Chung-Cheng University.
 2002 Prentice Hall. All rights reserved. 1 Chapter 4 – Control Structures Part 1 Outline 4.1 Introduction 4.2 Algorithms 4.3 Pseudocode 4.4 Control Structures.
 2003 Prentice Hall, Inc. All rights reserved. 1 Will not cover 4.14, Thinking About Objects: Identifying Class Attributes Chapter 4 - Control Structures.
ALGORITHMS AND FLOWCHARTS. Why Algorithm is needed? 2 Computer Program ? Set of instructions to perform some specific task Is Program itself a Software.
Lecture 5: Layers of Control. Nested while Loops Problem Multiplying two numbers and outputting the result only if they are both less than 5. (i.e. Start.
CHAPTER 2.2 CONTROL STRUCTURES (ITERATION) Dr. Shady Yehia Elmashad.
Flow Charts And Pseudo Codes Grade 12. An algorithm is a complete step-by- step procedure for solving a problem or accomplishing a task.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Chapter 3 - Structured Program Development Outline.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Flow Control (while) Outline 3.7The While Repetition.
Program design Program Design Process has 2 phases:
ALGORITHMS AND FLOWCHARTS
Algorithm: procedure in terms of
ALGORITHMS AND FLOWCHARTS
CS111 Computer Programming
Computer Programming Flowchart.
Chapter 4 – Control Structures Part 1
ALGORITHMS AND FLOWCHARTS
Unit# 9: Computer Program Development
Algorithms & Pseudocode
MSIS 655 Advanced Business Applications Programming
Structured Program
Programming in Pseudocode
Chapter 3 - Structured Program Development
ALGORITHMS AND FLOWCHARTS
Chapter 3 – Control Structures
CSC128 FUNDAMENTALS OF COMPUTER PROBLEM SOLVING
Chapter 3 - Structured Program Development
EPSII 59:006 Spring 2004.
Structural Program Development: If, If-Else
Presentation transcript:

PSEUDOCODE C Programming Technique – Firdaus-Harun.com

Agenda Intro to Pseudocode Pseudocode vs Flowchart Technique – Write pseudocode Examples

What’s Pseudocode ? Artificial and Informal language Helps programmers to plan an algorithm Similar to everyday English Not an actual programming language

E.g : Pseudocode Read A, B Calculate C = A*B Display C Stop

Technique Do not write Start in every pseudocode Parallelogram – Read / Get OR Display / Print Rectangle – Specify the actions ◦ E.g:  Calculate A = B + C OR A equals to B plus C  Average = total / count  Final price equals price of item plus sales tax Diamond – [Next »]

Technique (..Cont.) Diamond ◦ Selection – IF, IF / ELSE and IF / ELSE IF IF A is less than B BIG = B SMALL = A ELSE BIG = A SMALL = B ◦ Repetition – WHILE / DO/WHILE / FOR [Next example]

Comparative Between Flowchart vs Pseudocode Flowchart ◦ A graphical way of writing pseudocode ◦ Rounded rectangle – terminal ◦ Parallelogram – input / output ◦ Rectangle – actions ◦ Diamonds – decision / conditional ◦ Circles – connector

E.g : Flowchart Start Terminal. Program start here Stop Terminal Program end here Input. Enter values for A and B ProcessOutput

Comparative Between Flowchart vs Pseudocode (..Cont.) Pseudocode ◦ No syntax rule – Independent from any programming language ◦ Write in an ordinary language ◦ Uses a structure resembling computer structure ◦ No connector between pages

E.g : Pseudocode Read A, B Calculate C = A*B Display C Stop

E.g : Pseudocode Read A, B – Input Calculate C = A*B - Action Display C - Output Stop - Terminal

Example 2 (Selection) Read A, B IF A is less than B BIG = B SMALL = A ELSE BIG = A SMALL = B Write / Display BIG, SMALL Stop

Example 2 (Selection) Read A, B - Input IF A is less than B - Selection BIG = B - Action SMALL = A - Action ELSE - Selection BIG = A - Action SMALL = B - Action Write / Display BIG, SMALL - Output Stop - Terminal

Example 3 (Repetition) Set count to zero Set total to zero Read number WHILE ( not end-of-data ) increment count by 1 total = total + number read number IF ( count > 0 ) then average = total / count Display average Stop

Advantages Converting a pseudocode to a programming language is much more easier than converting a flowchart. As compared to flowchart, it is easier to modify a pseudocode of a program logic when program modifications are necessary.

Limitations In the cases of pseudocode, a graphic representation of program logic is not available. There are no standard rules to follow for using a pseudocode. ◦ Different programmers use their own style of writing pseudocode; and hence, ◦ Communication problem occurs due to lack of standardization.

Class Tutorial *Using previous Flowchart tutorial. Write a pseudocode to calculate Area and Perimeter of a trapezoid. Write an algorithm to set a Median for given number : ………………………..

Please Submit the Assignment

Review - Pseudocode An artificial and informal language that helps programmers develop algorithms A "text-based" detail (algorithmic) design tool “Write the steps before you write the code” (Matthew Morgenstern –Computer Scientist)

Example – IF/ELSE Read student ‘s grade IF student's grade is greater than or equal to 60 Print "passed" ELSE Print "failed“ Stop

Example - WHILE Set total to zero Set grade counter to one WHILE grade counter is less than or equal to ten Input the next grade Add the grade into the total Set the class average to the total divided by ten Print the class average Stop

Example – WHILE & IF/ELSE Initialize total to zero Initialize counter to zero Input the first grade WHILE the user has not as yet entered the sentinel Add this grade into the running total Add one to the grade counter Input the next grade (possibly the sentinel) IF the counter is not equal to zero Set the average to the total divided by the counter Print the average ELSE Print “no grades were entered” Stop

EXAMPLE – WHILE & IF/ELSE Initialize passes to zero Initialize failures to zero Initialize student to one WHILE student counter is less than or equal to ten Input the next exam result IF the student passed Add one to passes ELSE Add one to failures Add one to student counter Print the number of passes Print the number of failures IF eight or more students passed Print "raise tuition“ Stop

Assignment 2: Pseudocode Please do this assignment as pair work. Your partner must be not same as previous assignment 1. Due date : 27 th July 2009 (in class)