Desinging Programs With Flow Charts

Slides:



Advertisements
Similar presentations
UNIT 2. Introduction to Computer Programming
Advertisements

The Program Design Phases
PRE-PROGRAMMING PHASE
Fundamentals of C programming
ALGORITHMS AND FLOWCHARTS
CSC103: Introduction to Computer and Programming
1. Know the different types of flow block 2. Understand how problems can be broken down into smaller problems.
PROGRAMMING, ALGORITHMS AND FLOWCHARTS
Flow Charting. Goals Create Algorithms using Flow Charting procedures. Distinguish between Flow Charting and Pseudocode. Top-Down Design Bottom-up Design.
Describe the Program Development Cycle. Program Development Cycle The program development cycle is a series of steps programmers use to build computer.
By the end of this session you should be able to...
Problem Solving Techniques. Compiler n Is a computer program whose purpose is to take a description of a desired program coded in a programming language.
ITEC113 Algorithms and Programming Techniques
Dale Roberts 1 Program Control - Algorithms Department of Computer and Information Science, School of Science, IUPUI CSCI N305.
PROGRAM DEVELOPMENT CYCLE. Problem Statement: Problem Statement help diagnose the situation so that your focus is on the problem, helpful tools at this.
`. Lecture Overview Structure Programming Basic Control of Structure Programming Selection Logical Operations Iteration Flowchart.
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.
CPSC 233 Tutorial 5 February 2 th /3 th, Java Loop Statements A portion of a program that repeats a statement or a group of statements is called.
Flow Control in Imperative Languages. Activity 1 What does the word: ‘Imperative’ mean? 5mins …having CONTROL and ORDER!
 Problem Analysis  Coding  Debugging  Testing.
Pseudocode (pronounced SOO-doh-kohd)  is a detailed yet readable description of what a computer program or algorithm must do, expressed in a formally-styled.
Creating a Flowchart Computer Integrated Manufacturing
ALGORITHMS AND FLOWCHARTS
REPETITION CONTROL STRUCTURE
GC211Data Structure Lecture2 Sara Alhajjam.
Chapter 2- Visual Basic Schneider
C Program Controls + Flow Structure
ALGORITHMS AND FLOWCHARTS
CS1371 Introduction to Computing for Engineers
Introduction To Flowcharting
Programming Fundamentals
Lecture 07 More Repetition Richard Gesick.
Lecture 4B More Repetition Richard Gesick
Problem Solving (design of programs) CS140: Introduction to Computing 1 8/26/13.
Control Structures - Repetition
ALGORITHMS AND FLOWCHARTS
Pseudo-code Komate AMPHAWAN.
LESSON 11 – WHILE LOOPS UNIT 5 – 1/10/17.
Unit# 9: Computer Program Development
Problem-Solving and Control Structures By Faith Brenner
Program Design Introduction to Computer Programming By:
Global Challenge Night Sensor Lesson 2.
ALGORITHMS AND FLOWCHARTS
Chapter 2- Visual Basic Schneider
Global Challenge Night Sensor Lesson 2.
Introduction to Algorithms and Programming
` Structured Programming & Flowchart
Faculty of Computer Science & Information System
Chapter 2- Visual Basic Schneider
Global Challenge Night Sensor Lesson 2.
Global Challenge Night Sensor Lesson 2.
Problem Solving Designing Algorithms.
Computing Fundamentals
Computer Science Core Concepts
Global Challenge Night Sensor Lesson 2.
Problem-Solving and Control Structures By Faith Brenner
Global Challenge Night Sensor Lesson 2.
Global Challenge Night Sensor Lesson 2.
CHAPTER 4 Iterative Structure.
Flowcharts and Pseudo Code
Global Challenge Night Sensor Lesson 2.
The structure of programming
Introduction to Computer Science
Global Challenge Night Sensor Lesson 2.
Basic Concepts of Algorithm
Global Challenge Night Sensor Lesson 2.
The structure of programming
Thinking procedurally
WJEC GCSE Computer Science
Presentation transcript:

Desinging Programs With Flow Charts Komate AMPHAWAN CS-Unplug 22 July 2016 --Komate AMPHAWAN

Why using Flow-chart? CS-Unplug 22 July 2016 --Komate AMPHAWAN

Starter & Beginner Usually do like this … CS-Unplug 22 July 2016 --Komate AMPHAWAN

Starter & Beginner Usually do like this … CS-Unplug 22 July 2016 --Komate AMPHAWAN

Starter & Beginner Usually do like this … CS-Unplug 22 July 2016 --Komate AMPHAWAN

Starter & Beginner Usually do like this … CS-Unplug 22 July 2016 --Komate AMPHAWAN

Starter & Beginner Usually do like this … CS-Unplug 22 July 2016 --Komate AMPHAWAN

Starter & Beginner Usually do like this … CS-Unplug 22 July 2016 --Komate AMPHAWAN

IN practice CS-Unplug 22 July 2016 --Komate AMPHAWAN

What is a flow chart? Flow charts are a graphical method of designing programs and once the rules are learned are very easy to draw. CS-Unplug 22 July 2016 --Komate AMPHAWAN

A well-drawn flow chart is also very easy to read since it basically uses just two symbols, two decision constructs, and two iteration constructs: the sequence symbol, the decision symbol, the decision construct if ... then, the decision construct if ... then ... else, the repetition construct - repeat, the repetition construct - while, CS-Unplug 22 July 2016 --Komate AMPHAWAN

The language of flow charts The major symbols are the DECISION (also known as selection) and the SEQUENCE (or process) symbols. The START and STOP symbols are called the terminals. The SUBPROCESS symbol is a variation on the sequence symbol. There are also connectors drawn between the symbols and you will see these used in the examples below. CS-Unplug 22 July 2016 --Komate AMPHAWAN

Repeat loop Note that the repeat loop has the process preceding the decision. This means that a repeat loop will always execute the process part at least once. This is an important point to remember because it may not be what you want to do. For instance assume you are a world power in control of an arsenal of nuclear weapons and have written a program to launch missiles in the event of an attack. CS-Unplug 22 July 2016 --Komate AMPHAWAN

Repeat loop Your program contains a loop which launches a missile each time you are struck by an enemy missile, for example: REPEAT    LAUNCH MISSILE  UNTIL ENEMY STOPS CS-Unplug 22 July 2016 --Komate AMPHAWAN

Repeat loop Is a repeat loop a good idea in this case? Probably not since, if we assume you are not under attack and you run the program, the repeat loop executes the process at least once and you will probably start the next world war. A while loop would be a safer  CS-Unplug 22 July 2016 --Komate AMPHAWAN

While loop The while loop is basically the reverse of the repeat loop, the decision comes first, followed by the process. The while loop is usually written so that it iterates while the condition is true, the repeat iterates until the condition becomes true. CS-Unplug 22 July 2016 --Komate AMPHAWAN

While loop An interesting question is: When should a repeat loop be used rather than a while loop? and vice-versa. The while loop should be used when it is possible that the process or processes which are in the scope of the decision (that is, in the loop) may not need to execute. CS-Unplug 22 July 2016 --Komate AMPHAWAN

While loop For example assume you have a designed an air-conditioner controller program and the program turns on the compressor while the ambient temperature is above the desired temperature. CS-Unplug 22 July 2016 --Komate AMPHAWAN

 IF ... THEN  The IF ... THEN construct is shown here and is also known as the NULL ELSE, meaning that there is no ELSE part. I have use lines with arrow-heads (connectors) to indicate the flow of sequence. CS-Unplug 22 July 2016 --Komate AMPHAWAN

 IF ... THEN  Although this is important in flow charts once you have gained some skill in using them and if you draw them carefully you will find that determining the sequence is straight forward. A typical rule is to use arrow-heads on connectors where flow direction may not be obvious. CS-Unplug 22 July 2016 --Komate AMPHAWAN

 IF ... THEN ... ELSE ...  The IF ... THEN ... ELSE ... construct has a process at each branch of the decision symbol.  The only difference here is that each value of the decision  (TRUE/FALSE) has a process associated with it. CS-Unplug 22 July 2016 --Komate AMPHAWAN

Example CS-Unplug 22 July 2016 --Komate AMPHAWAN

Example Input is a positive integer expressing temperature in a room. Your task is to check whether the temperature in the room is “Below” or “Above” freezing (the freezing point is 32). If it is “Below” freezing point, show “Below Freezing” If it is “Above” freezing point, show “Above Freezing” CS-Unplug 22 July 2016 --Komate AMPHAWAN

Example CS-Unplug 22 July 2016 --Komate AMPHAWAN

Example CS-Unplug 22 July 2016 --Komate AMPHAWAN

Example CS-Unplug 22 July 2016 --Komate AMPHAWAN

Example CS-Unplug 22 July 2016 --Komate AMPHAWAN

Example CS-Unplug 22 July 2016 --Komate AMPHAWAN

E_ _ _ Exercise CS-Unplug 22 July 2016 --Komate AMPHAWAN

E_ _ _ Exercise Sums all the even numbers between 1 and 20 inclusive and then displays the sum. The equivalent pseudocode is:  sum = 0   count = 1   REPEAT     IF count is even THEN sum = sum + count     count = count + 1   UNTIL count > 20   DISPLAY sum CS-Unplug 22 July 2016 --Komate AMPHAWAN

E_ _ _ Exercise sum = 0 count = 1 REPEAT IF count is even THEN sum = sum + count     count = count + 1   UNTIL count > 20   DISPLAY sum CS-Unplug 22 July 2016 --Komate AMPHAWAN

E_ _ _ Exercise The major reasons are that the flow chart. is easier to read more closely follows a standard, this is not the the case with pseudocode probably lends itself more readily to computer-aided techniques of program design CS-Unplug 22 July 2016 --Komate AMPHAWAN

Reference http://users.evtek.fi/~jaanah/IntroC/DBeech/3gl_flo w.htm http://cprogrammingcodes.blogspot.com/2011/09/ algorithms-and-flowchart.html CS-Unplug 22 July 2016 --Komate AMPHAWAN