Flow Charts And Pseudo Codes Grade 12. An algorithm is a complete step-by- step procedure for solving a problem or accomplishing a task.

Slides:



Advertisements
Similar presentations
ALGORITHMS AND FLOWCHARTS
Advertisements

Chapter 2: Problem Solving
Flow Control Analysis & Design Tool: Flowcharts
UNIT 2. Introduction to Computer Programming
Chapter 3 IFTHENELSE Control Structure © 2008 Pearson Education Inc., Upper Saddle River, NJ. All rights reserved. Marilyn Bohl/Maria Rynn Tools for Structured.
Introduction to Flowcharting A Supplement to Starting Out with C++, 4th Edition by Tony Gaddis Published by Addison-Wesley.
Subject: Information Technology Grade: 10
Computer Programming Rattapoom Waranusast Department of Electrical and Computer Engineering Faculty of Engineering, Naresuan University.
Fundamentals of Algorithms MCS - 2 Lecture # 4
Chapter 2- Visual Basic Schneider
Developing logic (Examples on algorithm and flowchart)
Review Algorithm Analysis Problem Solving Space Complexity
ALGORITHMS AND FLOW CHARTS 1 Adapted from the slides Prepared by Department of Preparatory year Prepared by: lec. Ghader Kurdi.
Algorithm & Flowchart.
Fundamentals of C programming
Chapter 1 Pseudocode & Flowcharts
ALGORITHMS AND FLOWCHARTS
Adapted from slides by Marie desJardins
CSC103: Introduction to Computer and Programming
PROGRAMMING, ALGORITHMS AND FLOWCHARTS
An ordered sequence of unambiguous and well-defined instructions that performs some task and halts in finite time Let's examine the four parts of this.
Algorithmic Problem Solving CMSC 201 Adapted from slides by Marie desJardins (Spring 2015 Prof Chang version)
Structured Program Development Outline 2.1Introduction 2.2Algorithms 2.3Pseudo code 2.4Control Structures 2.5The If Selection Structure 2.6The If/Else.
Extended Prelude to Programming Concepts & Design, 3/e by Stewart Venit and Elizabeth Drake Chapter 2: Flowcharts.
CSE 102 Introduction to Computer Engineering What is an Algorithm?
CHAPTER 3 SELECTION STRUCTURE.
Software Life Cycle What Requirements Gathering, Problem definition
Lecture 2: Logical Problems with Choices. Problem Solving Before writing a program Have a thorough understanding of the problem Carefully plan an approach.
PSEUDOCODE C Programming Technique – Firdaus-Harun.com.
An Introduction to Programming with C++ Sixth Edition Chapter 7 The Repetition Structure.
ALGORITHMS AND FLOWCHARTS CSCI 105 – Computer Fluency.
ITEC113 Algorithms and Programming Techniques
`. Lecture Overview Structure Programming Basic Control of Structure Programming Selection Logical Operations Iteration Flowchart.
(C)opyright 2000 Scott/Jones Publishers Introduction to Flowcharting.
Fundamentals of Algorithms MCS - 2 Lecture # 5. Representation of Algorithms (continued) Flowcharts.
Topic: Control Statements. Recap of Sequence Control Structure Write a program that accepts the basic salary and allowance amount for an employee and.
Topics: Selection Statements. Processing Involving Selecting Instructions An instruction that allows deviation and selection to take place uses the ‘IF’
Algorithms and Pseudocode
ALGORITHMS AND FLOWCHARTS. Why Algorithm is needed? 2 Computer Program ? Set of instructions to perform some specific task Is Program itself a Software.
STEP 3- DEVELOP AN ALGORITHM At this stage we break down the problem into simple manageable steps so that they can be handled easily.
ALGORITHMS AND FLOWCHARTS. A typical programming task can be divided into two phases: Problem solving phase  produce an ordered sequence of steps that.
Fundamentals of Algorithms MCS - 2 Lecture # 3. Representation of Algorithms.
Introduction to Flowcharts
Program Program is a collection of instructions that will perform some task.
Lecture 2: Introduction to Programming EEE2108: 공학프로그래밍 서강대학교 전자공학과 2011 학년도 2 학기 - Algorithms and Flowcharts -
CSE 110: Programming Language I Matin Saad Abdullah UB 404.
Program design Program Design Process has 2 phases:
ALGORITHMS AND FLOWCHARTS
GC101 Introduction to computers and programs
Lesson 2 Flowcharting.
ALGORITHMS AND FLOWCHARTS
COVERED BASICS ABOUT ALGORITHMS AND FLOWCHARTS
PROGRAM CONTROL STRUCTURE
Computer Programming Flowchart.
Algorithms and Flowcharts
Lecture 2 Introduction to Programming
Introduction To Flowcharting
Numbering System TODAY AND TOMORROW 11th Edition
ALGORITHMS AND FLOWCHARTS
Control Structure Senior Lecturer
Lecture 2: Logical Problems with Choices
Unit# 9: Computer Program Development
ALGORITHMS AND FLOWCHARTS
Algorithms & Pseudocode
ALGORITHMS AND FLOWCHARTS
Introduction to Algorithms and Programming
` Structured Programming & Flowchart
ME 142 Engineering Computation I
Flowcharts and Pseudo Code
Introduction to Programming
Presentation transcript:

Flow Charts And Pseudo Codes Grade 12

An algorithm is a complete step-by- step procedure for solving a problem or accomplishing a task

 Flowcharts  Pseudo Codes

 It is a step by step Diagrammatic representation of the program  Each type of task is represented by a symbol

Diagram Notation Representation Oval Start / End of a Program Parallelogram Input / Output of Data Rectangle Processing Operation Rhombus Decision Box

Diagram Notation Representation CircleConnection Flow Lines Direction of Flow Rectangle Sub Process

Outputs Start Stop Inputs Calculations Output Sum Start Stop Input a, b Sum = a + b Eg :

Sequence Selection Iteration

 SEQUENCE is a linear progression where one task is performed sequentially after another. Statement 1 Statement 3 Statement 2 START STOP

Find the sum and average of two numbers Start Input Number1 Input Number1 Input Number2 Input Number2 Sum = 0 Average = 0 Sum = 0 Average = 0 Average = Sum / 2 Display Sum, Average Display Sum, Average Stop Sum = Numbe1 + Number2

SELECTION - there may be alternative steps that could be taken subject to a particular condition IF-THEN-ELSE is a decision (selection) in which a choice is made between two alternative courses of action

Condition? Statement sequence 1 Statement sequence 2 FalseTrue

Input the length and width of a quadrilateral and state whether it is a square Start Get Length Get Length Get Width Get Width Is Length equal to Width ? Display “Figure is Square” Display “Figure is Square” Stop Y N

Input the length and width of a quadrilateral and state whether it is a square or a rectangle. Start Get Length, width Is Length equal Width ? Is Length equal Width ? Display “Figure is Square” Display “Figure is Square” Stop Y N Display “Figure is Rectangle” Display “Figure is Rectangle”

Connectors  When a flowchart is too long to fit on a page and is to be continued on another page a connector symbol is used  A small circle is used to represent a connector in a flowchart  An alphabet or a number is written inside the circle to identify the pairs of connectors to be joined

A A Set value of Counter to 0 Set value of Total to 0 Get Number Start B B Add number to value of total Increment counter by 1 A A Is Counter = 10? Is Counter = 10? B B Write total Stop Y N

 ITERATION - certain steps may need to be repeated while, or until, a certain condition is true While For Repeat

while Condition ? Condition ? Statement sequence Statement sequence true false Start loop End loop

Find the sum of 10 numbers Display total Counter< 10 ? Start counter = 0 total = 0 Stop Get Number total = total+number counter=counter+1 yes No

For Control_variable < end_value ? Control_variable < end_value ? Control_variable = Start Value true false Control_variable = Control_variable+1 Statement-sequence Start For End For

Display the numbers 1, 2, 3, 4, 5, ….., 100 Start Stop no = 1 no <= 100 Display no no = no + 1 false true

Example -7 Enter marks of 4 subjects and find the average. If the average is less than 50 then display “pass” else display “fail”.

Start Input m1, m2, m3, m4 IF Average < 50 Display “Pass” Display “Pass” Stop true N Display “Fail” Display “Fail” average = 0 average = ( m1 + m2 + m3 + m4 ) /4 false

Example -8 A company gives discounts for the total bill paid by the customers. If the Bill amount is above Rs. 5000/-, a discount of 10 % is given. Otherwise 5% is given. Input the Bill amount and calculate the discount amount.

Start Input Bill_Amount IF Bill_Amount > = 5000 IF Bill_Amount > = 5000 Stop true Display Discount Display Discount discount = 0 Discount = Bill_Amount * 0.10 false Discount = Bill_Amount * 0.05

Example - 9 A company pays a basic salary of Rs. 8000/- to the salesmen. If a salesman does sales of Rs. 50,000/- or above, he is given a 25% commission. Otherwise only 10%. Input the sales done by a salesman and calculate his salary for the month.

Start Input Sales_Amount IF Sales_Amount > = IF Sales_Amount > = Stop true Display Tot_Salary Commission = 0, Tot_Salary = 0 Commission = Sales_Amount * 0.25 false Commission = Sales_Amount * 0.10 Tot_Salary = Commission

Pseudo codes use every day language … to prepare a brief set of instructions … in the order … in which they will appear in a finished program It is an abbreviated version of actual computer code (that ’ s why it is called Pseudocode) Once pseudocode is created, it is simple to translate into real programming code.

Sequence –Use set of instructions one after the other Selection –Use IF … THEN … ELSE Repetition –Use WHILE, FOR, REPEAT…UNTILL

Sequence Statement 1 Statement 3 Statement 2 START STOP Pseudocode; statement 1 statement 2 statement 3

Example - 10 Write a pseudo code that inputs two numbers (a and b) and calculates the sum of the numbers and output the sum INPUT a INPUT b sum = a + b OUTPUT sum

Compare and Select One of Two Alternative ActionsCompare and Select One of Two Alternative Actions Select one path according to the condition –IF …. THEN If the condition is true do the statements inside IF No operation if the condition is false –IF …. THEN …. ELSE If the condition is true do the statements inside IF If the condition is false do the statements inside ELSE

IF Condition? Statement sequence 1 ENDIF Statement sequence 2 FalseTrue Pseudocode: IF condition THEN sequence-1(statements) ELSE sequence-2(statements) ENDIF

IF THEN sequence 1 ENDIF IF THEN sequence 1 ELSE sequence 2 ENDIF Example1: IF a>0 THEN Print a END IF Example2: IF a>b THEN Print a ELSE Print b END IF

Example-11 Write a pseudo code that inputs two numbers (a and b) and output the largest number. INPUT a INPUT b IF a < b THEN OUTPUT b ELSE OUTPUT a END IF

–WHILE … ENDWHILE

While Condition ? Condition ? Statement sequence Statement sequence true false EndWhile Pseudocode: WHILE Statement- Sequence END WHILE

Example - 12 Inputs 5 numbers and outputs the sum and average of them. count = 1 sum = 0 WHILE count <= 5 Do INPUT num sum = sum + num count = count + 1 END WHILE average = sum / 5 DISPLAY sum, average