Fundamentals of Algorithms MCS - 2 Lecture # 5. Representation of Algorithms (continued) Flowcharts.

Slides:



Advertisements
Similar presentations
ALGORITHMS AND FLOWCHARTS
Advertisements

Summer ’12 AP Computer Science APCS Summer Assignments Read thoroughly this ppt and solve examples 6 and 7.
CS 240 Computer Programming 1
ALGORITHMS AND FLOWCHARTS
PROBLEM SOLVING TECHNIQUES
CHAPTER 2 GC101 Program’s algorithm 1. COMMUNICATING WITH A COMPUTER  Programming languages bridge the gap between human thought processes and computer.
Chapter 2: Problem Solving
UNIT 2. Introduction to Computer Programming
Chapter 2: Problem Solving
Introduction to Flowcharting A Supplement to Starting Out with C++, 4th Edition by Tony Gaddis Published by Addison-Wesley.
ME 142 Engineering Computation I Fundamentals of Procedural Computer Programming.
ALGORITHMS AND FLOWCHARTS
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)
The Program Design Phases
Algorithm & Flowchart.
Fundamentals of C programming
ALGORITHMS AND FLOWCHARTS
DCT 1123 Problem Solving & Algorithms
Chapter 2: Problem Solving
CSEB114: PRINCIPLE OF PROGRAMMING Chapter 2: Problem Solving.
Chapter 2: Problem Solving
PROGRAMMING, ALGORITHMS AND FLOWCHARTS
U NDERSTANDING P ROBLEMS AND HOW TO S OLVE THEM BY USING C OMPUTERS.
Flow Charting. Goals Create Algorithms using Flow Charting procedures. Distinguish between Flow Charting and Pseudocode. Top-Down Design Bottom-up Design.
Design the program Create a detailed description of program –Use charts or ordinary language (pseudocode) Identify algorithms needed –Algorithm: a step-by-step.
PROGRAMMING LANGUAGES Prof. Lani Cantonjos. PROGRAM - set of step-by-step instructions that tells or directs the computer what to do. PROGRAMMING LANGUAGE.
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.
Flowcharts! January 13, 2005 These are today’s notes! Do you think we will get more snow?
End Show Writing a computer program involves performing the following tasks. 1. Understanding the problem 2. Developing an Algorithm for the problem 3.
Algorithm & Flow Charts
A step-by-step procedure for solving a problem in a finite number of steps.
ALGORITHMS AND FLOWCHARTS CSCI 105 – Computer Fluency.
Flowcharting & Algorithms. Quick. Close your Eyes and Listen You are still sitting in the classroom. However, you have been called to the counselor’s.
Principles of Programming - NI July Chapter 2: Problem Solving In this chapter you will learn about: Introduction to Problem Solving Software development.
1 Program Planning and Design Important stages before actual program is written.
Introduction to Computing Dr. Nadeem A Khan. Lecture 2.
 In this chapter you will learn about:  Introduction to Problem Solving  Software development method (SDM)  Specification of needs  Problem analysis.
CSEB114: Principle of programming
Concepts of Algorithms CSC-244 Unit Zero Pseudo code, Flowchart and Algorithm Master Prince Computer College Qassim University K.S.A.
FLOWCHARTING AND ALGORITHMS
Programming Fundamentals Introduction to Problem Solving  Programming is a problem solving activity. When you write a program, you are actually writing.
ALGORITHMS AND FLOWCHARTS. A typical programming task can be divided into two phases: Problem solving phase  produce an ordered sequence of steps that.
Lecture 2: Introduction to Programming EEE2108: 공학프로그래밍 서강대학교 전자공학과 2011 학년도 2 학기 - Algorithms and Flowcharts -
| MSC 8102:PROGRAMMING CONCEPTS By Vincent Omwenga, PhD. 1.
Flow Charts And Pseudo Codes Grade 12. An algorithm is a complete step-by- step procedure for solving a problem or accomplishing a task.
 Problem Analysis  Coding  Debugging  Testing.
Problem Solving & Computer Programming
ALGORITHMS AND FLOWCHARTS
GC101 Introduction to computers and programs
Unit 3: ALGORITHMS AND FLOWCHARTS
COVERED BASICS ABOUT ALGORITHMS AND FLOWCHARTS
Introduction to Computing
CS111 Computer Programming
Algorithms and Flowcharts
Introduction To Flowcharting
Numbering System TODAY AND TOMORROW 11th Edition
ALGORITHMS AND FLOWCHARTS
Unit# 9: Computer Program Development
ALGORITHMS AND FLOWCHARTS
ALGORITHMS AND FLOWCHARTS
Introduction to Algorithms and Programming
Faculty of Computer Science & Information System
Chapter 2- Visual Basic Schneider
ME 142 Engineering Computation I
Understanding Problems and how to Solve them by using Computers
Flowcharts and Pseudo Code
Introduction to Programming
Presentation transcript:

Fundamentals of Algorithms MCS - 2 Lecture # 5

Representation of Algorithms (continued) Flowcharts

Pseudo code Example  Write an algorithm to determine a student’s final grade and indicate whether it is passing or failing. The final grade is calculated as the average of four marks.  Pseudo code Input a set of 4 marks Calculate their average by summing and dividing by 4 if average is below 60 Print “FAIL” else Print “PASS”

Detailed Algorithm Step 1: Input M1,M2,M3,M4 Step 2: GRADE ← (M1+M2+M3+M4) / 4 Step 3: if (GRADE < 60) then Print “FAIL” else Print “PASS” endif

Definition of Flowchart  A flowchart is a type of diagram that represents an algorithm or process, showing the steps as boxes of various kinds, and their order by connecting them with arrows. A flowchart  shows logic solution,  emphasizes individual steps and their interconnections,  A flowchart must have a start and stop,  A steps in a flowchart must connect. Can’t leave a step “hanging” with no connection.

Flow Charts  Flowcharts are a graphical means of representing an algorithm.  Advantages  Flowchart permit the structure of a program to be easily visualized - even if all the text were to be removed.  The human brain is very good at picking out these patterns and keeping them "in the back of the mind" as a reference frame for viewing the code as it develops.

7 Terminal symbol - indicates the beginning and end points of an algorithm. Process symbol - shows an instruction other than input, output or selection. Input-output symbol - shows an input or an output operation. Disk storage I/O symbol - indicates input from or output to disk storage. Basic Flowchart Shapes

8 Selection symbol - shows a selection process for two-way selection. Off-page connector - provides continuation of a logical path on another page. On-page connector - provides continuation of logical path at another point in the same page. Flow lines - indicate the logical sequence of execution steps in the algorithm. Basic Flowchart Shapes

Flowchart – sequence control structure 9 Statement 2 Statement 1 Statement 3 :

Flowchart – selection control structure 10 Condition else- statement(s) then- statement(s) YesNo Pseudocode IF: (test condition) Statement TRUE ELSE: Statement FALSE

Flowchart – repetition control structure 11 Condition Loop Statement(s) yes no

Flowchart – example 1 12 Begin Read birth date Calculate Age = current year – birth date Display age End Pseudocode GET Birth Year SET age= Current year- Birth Year PUT Age

Flowchart – example 2 13 Begin Read age End Age > 55? NOYES print “Pencen” print “Kerja lagi”

Flowchart – example 5 14 Begin End current_number <= 10? NO YES sum = 0 current_number = 1 sum = sum + current_number current_number = current_number + 1 print sum

assignment # 2 1.Write an algorithm to calculate the sum of the digits of a three digit number.  Trace the algorithm using the number Write an algorithm to calculate the average mark out of 100, given three assignment marks, each of which is marked out of 20.  Trace the algorithm using 15, 20 and 10 as the three assignment marks. 3.Write an algorithm to sum four numbers and return the sum in the variable x.  Trace the algorithm using w as 2, x as 3, y as 4 and z as 5.

Good Luck ! ☻