Flowcharts. Symbol Terminal Symbol: indicates the starting or stopping pointin the logic. Input/Output Symbol: Represents an input or output process in.

Slides:



Advertisements
Similar presentations
Repetition There are three different ways that a set of instructions can be repeated, and each way is determined by where the decision to repeat is.
Advertisements

Repetition Control Structures
Flow Charts, Loop Structures
Introduction to Flowcharting
Introduction to Flowcharting
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
Selection control structures
Assistanship Assistant: Denny, TE 2002 Type: not compulsary, only when necessary Duration: once a week, not more than 2 hours. Time,place: ask assistant.
TEL 104 / MKK Fundamental Programming: Lecture 3
Chapter 2- Visual Basic Schneider
Nassi-Schneidermann Diagrams Lecture 13. Three basic control Structures.
Logic and Algorithm. Developing an algorithm To help the initial analysis, the problem should be divided into 3 separate components: 1.Input: a list of.
1 TEL 104 / MKK Fundamental Programming: Lecture 4.
Program Design and Development
Flowcharts Remember that a solution to a problem is called an algorithm. Algorithms are often a series of steps required to solve the problem. A flowchart.
Modularisation II Lecture 9. Communication between modules Also known as intermodule communication. The fewer and the simpler the communications, the.
Array Processing Lecture 7.
Repetition Control Structures
Developing logic (Examples on algorithm and flowchart)
Pseudocode.
Chapter 1 Pseudocode & Flowcharts
DCT 1123 Problem Solving & Algorithms
Sw development1 Software Development 1.Define the problem (Analysis) 2.Plan the solution 3.Code 4.Test and debug 5.Maintain and Document.
Combination of Sequence, Selection and Repetition
Pseudocode algorithms using sequence, selection and repetition
DCT 1123 Problem Solving & Algorithms
Looping While-continue.
Array Processing Simple Program Design Third Edition A Step-by-Step Approach 7.
1 Introduction to Flowcharting. 2 Writing a program Defining the problem –Write down what the program will do Planning –Write down the steps, draw a flowchart.
Developing an Algorithm
Introduction to Computers (L02) * Hardware * Software * Programming Languages * Three Phase of Program Development * Development and Design Steps * Algorithms.
Chapter 7 Array processing. Objectives To introduce arrays and the uses of arrays To develop pseudocode algorithms for common operations on arrays To.
Array Processing.
The while Loop Syntax while (condition) { statements } As long condition is true, the statements in the while loop execute.
Selection Control Structures. Simple Program Design, Fourth Edition Chapter 4 2 Objectives In this chapter you will be able to: Elaborate on the uses.
© 2011 Pearson Addison-Wesley. All rights reserved. Addison Wesley is an imprint of Stewart Venit ~ Elizabeth Drake Developing a Program.
More While Loop Examples CS303E: Elements of Computers and Programming.
Developing an Algorithm
Pseudocode. Simple Program Design, Fourth Edition Chapter 2 2 Objectives In this chapter you will be able to: Introduce common words, keywords, and meaningful.
Visual Basic Programming
Pseudocode Algorithms Using Sequence, Selection, and Repetition
EXERCISES for ALGORITHMS WRITING
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.
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.
(C)opyright 2000 Scott/Jones Publishers Introduction to Flowcharting.
Motivation Complexity of programming problem  more difficult to consider the solution as a whole  clue: dividing the problem into small parts (module)
Computer Programming CONTENTS Introduction to Operating Systems Introduction to programming languages Introduction to perl programming language Programming.
Flowcharts Lecture 12.
Topic: Control Statements. Recap of Sequence Control Structure Write a program that accepts the basic salary and allowance amount for an employee and.
1 Introduction to Flowcharting Computer Science Principles ASFA.
Chapter 2- Visual Basic Schneider1 Chapter 2 Problem Solving.
STEP 3- DEVELOP AN ALGORITHM At this stage we break down the problem into simple manageable steps so that they can be handled easily.
Flowchart Symbols Terminal Process Input/ Output Decision
REPETITION CONTROL STRUCTURE
1-1 Logic and Syntax A computer program is a solution to a problem.
Chapter 2- Visual Basic Schneider
PROGRAM CONTROL STRUCTURE
Introduction to Flowcharting
Pseudocode algorithms using sequence, selection and repetition
Chapter 2- Visual Basic Schneider
Chapter 2- Visual Basic Schneider
Introduction to Flowcharting
Assistanship Assistant : Denny, TE 2002
Chapter 5 Desk Checking/Dry Running.
Introduction to Pseudocode
Presentation transcript:

Flowcharts

Symbol Terminal Symbol: indicates the starting or stopping pointin the logic. Input/Output Symbol: Represents an input or output process in an algorithm Process Symbol: Represents any single process in an algorithm Decision Symbol: Represents a decision in the logic involving the comparison Of two values. Predefined Process Symbol:

The three basic control structures

1. Sequence Statemement a Statemement b Statemement c

2. Selection Condition p? Statemement a Statemement b TF

Selection (2) Condition p? Statemement a T F

3. Repetition Condition p? Statemement block T F

Example 12.1 Add three numbers  A program is required to read three numbers, add them together and print their total.

Defining diagram InputProcessingOutput Number1 Number2 Number3 Read three numbers Add number together Print total number total

Solution Algorithm Add numbers to total Read Number1 Number2 number3 Print total Start Stop

Example 12.2 Find average temperature A program is required to prompt the terminal operator for the maximum and minimum temperature readings on a particular day, accept those readings as integers, and calculate and display to the screen the average temperature, calculated by (maximum temperature + minimum temperature)/2.

Defining diagram InputProcessingOutput Max_temp Min_temp Prompt for temperatures Get temperatures Calculate average temperature Display average temperature Avg_temp

Solution Algorithm

Example 12.3 Compute mowing time A program is required to read from the screen the lenght and widht of a rectangular house block, and the lenght and width of the rectangular house that has been built on the block. The algorithm should then compute and display the mowing time required to cut the grass around the house, at the rate of two square metres per minute.

Defining diagram InputProcessingOutput Block_lenght Block_width House_lenght House_width Prompt for block measurements Get block measurements Prompt for house measurements Get house measurements Calculate mowing area Calculate mowing time Mowing_time

Solution Algorithm

Flowchart and the selection control structure

Simple IF statement Account_ balance < $300? Service_charge = $5 Service_charge = $2 TF

Null ELSE statement

Combined IF statement

Nested IF statement Increment Counter_A Record Code =`A‘ ? Increment Counter_B Increment Counter_C Increment Error_counter Record Code =`B‘ ? Record Code =`C‘ ? T T T F F F

Example 12.4 Read three characters Design an algorithm that will prompt a terminal operator for three characters, accept those characters as input, sort them into ascending sequence and output them to the screen.

Defining diagram InputProcessingOutput Char_1 Char_2 Char_3 Prompt for characters Accept three characters Sort three characters Output three characters Char_1 Char_2 Char_3

Solution Algorithm ?

Case Structure Case Of variable Statement_aStatement_bStatement_cStatement_d Value 1 Value 2Value 3Value 4

Flowchart and Array Design a program that will prompt for and receive 18 examination scores from a mathematics test, compute the class average, and display all the scores and the class average to the screen.

Defining diagram InputProcessingOutput 18 exam scoresPrompt the scores Get scores Compute class average Display scores Display class average 18 exam scores Class_average

Control Structures required 1.An array to store the exam scores – called ´scores´ 2.An index to identify each element in the array 3.A DO loop to accept the scores 4.Another DO loop to display the scores to the screen.

Solution Algorithm Start Total_score = zero I = 1 Add scores(I) to Total score I = I + 1 Calculate average I = I + 1 Prompt and get Scores (I) I = 1 I <= 18 ? Display Scores (I) I <= 18 ? Display average Stop T F T F

Flowchart and Module Design a solution algorithm that will prompt a terminal operator for three characters, accept those characters as input, sort them into ascending sequence and output them to the screen. The algorithm is to continue to read characters until ´XXX`is entered.

Defining diagram InputProcessingOutput Char_1 Char_2 Char_3 Prompt for characters Accept three characters Sort three characters Output three characters Char_1 Char_2 Char_3

Hierarchy chart Process_three_ characters Sort_three_ characters

Process_three_characters Start Prompt For characters Sort_ Three_ characters Outpur characters Get characters Prompt For characters Get characters Stop Characters NOT = xxx ? F T

Sort_three_characters

Thanks Finish!