Reference :Understanding Computers

Slides:



Advertisements
Similar presentations
How Are Algorithms Developed?
Advertisements

COMPUTER PROGRAMMING I Understand Problem Solving Tools to Design Programming Solutions.
Chapter 2: Problem Solving
Prof. B. I. Khodanpur HOD – Dept. of CSE R. V. College of Engineering
Flowcharts Amir Haider Lecturer NFC IEFR. Introduction The flowchart is a means of visually presenting the flow of data through an information processing.
UNIT 2. Introduction to Computer Programming
ALGORITHMS THIRD YEAR BANHA UNIVERSITY FACULTY OF COMPUTERS AND INFORMATIC Lecture two Dr. Hamdy M. Mousa.
Alexandria University Faculty of Science Computer Science Department
Flowchart TA. Maram Al-Khayyal.
Fundamentals of Algorithms MCS - 2 Lecture # 4
INTRODUCTION TO PROGRAMMING
Flowcharts.
ITEC113 Algorithms and Programming Techniques
Chapter 2- Visual Basic Schneider
Chapter 1 Program Design
Chapter 3 Planning Your Solution
The Program Design Phases
PRE-PROGRAMMING PHASE
ALGORITHMS AND FLOW CHARTS 1 Adapted from the slides Prepared by Department of Preparatory year Prepared by: lec. Ghader Kurdi.
Programming Logic and System Analysis
Algorithm & Flowchart.
Fundamentals of C programming
ALGORITHMS AND FLOWCHARTS
Lecture # 8 ALGORITHMS AND FLOWCHARTS. Algorithms The central concept underlying all computation is that of the algorithm ◦ An algorithm is a step-by-step.
Introduction to Programming Prof. Rommel Anthony Palomino Department of Computer Science and Information Technology Spring 2011.
PROGRAMMING, ALGORITHMS AND FLOWCHARTS
Programming Concepts Chapter 3.
Extended Prelude to Programming Concepts & Design, 3/e by Stewart Venit and Elizabeth Drake Chapter 2: Flowcharts.
Chapter 2 Problem Solving On A Computer 2.1 Problem Solving Steps Solving a problem on a computer requires steps similar to those followed when solving.
INTRODUCTION TO COMPUTING CHAPTER NO. 04. Programming Languages Program Algorithms and Pseudo Code Properties and Advantages of Algorithms Flowchart (Symbols.
1 Computer Programming (ECGD2102 ) Using MATLAB Instructor: Eng. Eman Al.Swaity Lecture (4): Control Flow (Chapter 2)
Visual Basic Programming
Flowcharting A Quality Improvement Tool. Quality = Inspection Statistical methods assisted in prevention of defects – The need for inspection declined.
Chapter 2: General Problem Solving Concepts
The Software Development Process
PROGRAM DEVELOPMENT CYCLE. Problem Statement: Problem Statement help diagnose the situation so that your focus is on the problem, helpful tools at this.
1 Program Planning and Design Important stages before actual program is written.
Introduction to Flow Chart It is pictorial representation of process of a system or processes. Types of Flow charts –Program Flow Chart –System Flow chart.
Fundamentals of Algorithms MCS - 2 Lecture # 5. Representation of Algorithms (continued) Flowcharts.
Structured Programming (4 Credits)
8.1 8 Algorithms Foundations of Computer Science  Cengage Learning.
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.
PROGRAMMING FUNDAMENTALS INTRODUCTION TO PROGRAMMING. Computer Programming Concepts. Flowchart. Structured Programming Design. Implementation Documentation.
Program Program is a collection of instructions that will perform some task.
Flow Charts And Pseudo Codes Grade 12. An algorithm is a complete step-by- step procedure for solving a problem or accomplishing a task.
Program Design & Development EE 201 C7-1 Spring
 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.
Chapter One Problem Solving
Understand Problem Solving Tools to Design Programming Solutions
Flow Charts Basic Flow Chart Symbols Few sample flowcharts Rules
MANUPLATION OF FLOWCHARTS
Chapter One Problem Solving
Flowcharting Guidelines
Chapter 2- Visual Basic Schneider
Understand Problem Solving Tools to Design Programming Solutions
Algorithms An algorithm is a sequence of steps written in the form of English phrases that specific the tasks that are performed while solving the problem.It.
Lecture 2 Introduction to Programming
2.0 Problem Solving PROGRAM DESIGN
Algorithm Algorithm is a step-by-step procedure or formula or set of instruction for solving a problem Its written in English language or natural language.
Introduction to Computer Programming
Unit# 9: Computer Program Development
Reference :Understanding Computers
Chapter 2- Visual Basic Schneider
CSC128 FUNDAMENTALS OF COMPUTER PROBLEM SOLVING
Chapter 2- Visual Basic Schneider
Lecture 7 Algorithm Design & Implementation. All problems can be solved by employing any one of the following building blocks or their combinations 1.
Basic Concepts of Algorithm
Presentation transcript:

Reference :Understanding Computers Flow Charts Reference :Understanding Computers Chapter 13

Definitions Flowchart: is a diagrammatic representation that illustrates the sequence of operations to be performed to get the solution of a problem.

Standard Symbols Used ? A A1 Start Print Results Calculate Variables Start Or Stop Process Start Print Results Input/Output A On-Page Connector ? Yes No Condition Calculate Variables Process Rectangle A1 Off-page Connector

How to Write a Program? Start Define Problem to Solve Think of an Algorithm Think of a Technique for the Solution Write Solution on a Piece of Paper If not Finished Repeat Steps 4 and 5 Write Code and Program Debug and Test If not Finished Repeat Steps 7 and 8 Stop

How to Write a Program ?(flowchart) Start Job Done? No Define Problem to Solve Think of an Algorithm (Technique for the solution) Yes Write Code and Program Idea!!!! Debug and Test Think of a Technique for the solution Job Done? No Yes Stop Write it down on a piece of paper (before you forget it!!!)

Definitions An Algorithm A computer program makes use of algorithms. Is a complete step-by-step procedure for solving a problem or accomplishing a task. ( Where the algorithm is represented by drawing “Flowcharts” )

Basic Flow Chart Operations All computer instructions are based on four basic processing patterns: Simple Sequence Selection Pattern Loop Pattern

1.Simple Sequence Logic involves executing instructions one statement after another, in the order presented by the program. This is the simplest and most-used pattern. The computer assumes that all instructions are to be executed in this order unless the program presents other instructions.

Read Names Compare with Criteria Print Eligible Names Basic Operations of Flow Charts (Simple Sequence) Read Names Compare with Criteria Basic Operations of Flow Charts (Simple Sequence) Print Eligible Names

2. Selection Pattern Requires that the computer make a choice among two or more items. Each choice is based on one of two comparisons a computer can make: true or false (Yes or No).

Basic Operations of Flow Charts (Selection Pattern) Honour Student? List under Student Loan Yes Scholarships No

3. Loop Pattern Directs the computer to loop back to a previous statement in the program, repeating the same sequence over again, usually with new data. By looping, the programmer avoids having to repeat the same set of instructions over and over

Basic Operations of Flow Charts (Loop Pattern) More Names? No Yes Compare with Criteria Print Eligible Names

Uses of Flow Charts Flowcharts play a vital role in the programming of a problem and are quite helpful in understanding the logic of complicated and lengthy problems. Once the flowchart is drawn, it becomes easy to write the program in any high level language. Often we see how flowcharts are helpful in explaining the program to others. Hence, it is correct to say that a flowchart is a must for the better documentation of a complex program.

Uses of Flow Charts……. Flow Charts document processes and interrelationships of process steps Flow Charts identify actual and ideal paths where any product or process flows Flow Charts are used to identify problems and potential improvements Flow Charts can be completed on entire processes assemblies with all components, one person or component through a process, combinations of people and machines, transactions following forms or other documents, etc.

Advantages of Flow Charts Communication: Flowcharts are better way of communicating the logic of a system to all concerned. Effective Analysis: With the help of flowchart, problem can be analysed in more effective way. Proper Documentation: Program flowcharts serve as a good program documentation, which is needed for various purposes.

Advantages of Flow Charts…. Efficient Coding: The flowcharts act as a guide or blueprint during the systems analysis and program development phase. Proper Debugging: The flowchart helps in debugging process. Efficient Program Maintenance: The maintenance of operating program becomes easy with the help of flowchart. It helps the programmer to put efforts more efficiently on that part.

Disadvantages of Flow Charts Complex Logic: Sometimes, the program logic is quite complicated. In that case, flowchart becomes complex and clumsy. Alterations and Modifications: If alterations are required the flowchart may require re-drawing completely. Reproduction: As the flowchart symbols cannot be typed, reproduction of flowchart becomes a problem. The Essentials of what Is Done can easily be lost in the technical details of how it is done.

Case Study - 1 A certain Company gives each of its sales people $1,000 at the beginning of each month to cover travel, lodging, and food expenses. At the end of the month, a salesperson must total his/her expense receipts. If the amount is less than $1,000 then the difference must be returned to the company. Case Study - 1

Case Study – 1 (Solution) Here is an algorithm for figuring how much money, if any, must be returned: 1-Total the expense receipts for the month. 2. Subtract the amount of the expense receipts from 1,000. 3. If the remainder is more than 0, return that amount to the company.

Case Study – 1 (Flow Chart) Start Input Expenses E Yes E<1000? Subtract Expenses R <= 1000-E No Print You Owe $0 Case Study – 1 (Flow Chart) Print You Owe $R Stop

Assume the Employee has Spent Case Study – 1 (Solution 1) Assume the Employee has Spent $1250 What would be the amount to return to the company in this case?

Case Study – 1 (Solution 1) Start Input Expenses E<1000 ? Yes E=$1250 Subtract Expenses R <= 1000-E No Print You Owe $0 R= $0 Print You Owe $R Stop

Case Study – 1 (Solution 2) Now Assume the Employee has Spent $950 What would be the amount to return to the company in this case?

Case Study – 1 (Solution 2) Start Input Expenses E<1000? E=$950 R = 1000 - E = $950 Yes Subtract Expenses R = 1000-E No R= $50 Print You Owe $0 Print You Owe $R Stop

Basic Guidelines for Flow Charting In drawing a proper flowchart, all necessary requirements should be listed out in logical order. The flowchart should be clear, neat and easy to follow. There should not be any room for ambiguity in understanding the flowchart. The usual direction of the flow of a procedure or system is from left to right or top to bottom

Basic Guidelines for Flow Charting(Cont.) Only one flow line should come out from a process symbol.

Basic Guidelines for Flow Charting (Cont.) Only one flow line should enter a decision symbol, but two or three flow lines, one for each possible answer, should leave the decision symbol. Y N ? < = ? >

Basic Guidelines for Flow Charting (Cont.) Only one flow line is used in conjunction with terminal symbol. Stop Start

Basic Guidelines for Flow Charting (Cont.) Write within standard symbols briefly. As necessary, you can use the annotation symbol to describe data or computational steps more clearly. If the flowchart becomes complex, it is better to use connector symbols to reduce the number of flow lines. Avoid the intersection of flow lines if you want to make it more effective and better way of communication. Basic Guidelines for Flow Charting (Cont.)

Basic Guidelines for Flow Charting (Cont.) Ensure that the flowchart has a logical start and finish. It is useful to test the validity of the flowchart by passing through it with a simple test data Basic Guidelines for Flow Charting (Cont.)

Case Study - 2 Draw a flowchart to find the sum of first 5 natural numbers.

Sum = 0 Stop N = 0 N = N + 1 ? N = 5 Start Sum = Sum + N No Yes Print Sum N Sum 1 1 2 3 3 6 4 10 5 15

Case Study - 3 Draw a flowchart to find the largest of three numbers A,B, and C.

Case Study - 3 Start Read A, B, C ? B > C ? A > B ? A > C Yes No Yes Yes No No Print B Print C Print C Print A Stop

Case Study – 3 - (Solutions) Consider four input cases: 1. A = 5 ; B = 7 ; C = 3 2. A = 5 ; B = 6 ; C = 7 3. A = 5 ; B = 3 ; C = 7 4. A = 5 ; B = 3 ; C = 3

Case Study – 3 (Solution 1) Start B = 7 Read A, B, C C = 3 ? B > C ? A > B ? A > C Yes No Yes Yes No No Print B Print C Print C Print A Stop

Case Study – 3 (Solution 2) Start B = 6 Read A, B, C C = 7 ? B > C ? A > B ? A > C Yes No Yes Yes No No Print B Print C Print C Print A Stop

Case Study – 3 (Solution 3) Start B = 3 Read A, B, C C = 7 ? B > C ? A > B ? A > C Yes No Yes Yes No No Print B Print C Print C Print A Stop

Case Study – 3 (Solution 4) Start B = 3 Read A, B, C C = 3 ? B > C ? A > B ? A > C Yes No Yes Yes No No Print B Print C Print C Print A Stop

Case Study - 4 Draw a flowchart for computing factorial N (N!). Where N! = 1 ´ 2 ´ 3 ´ …… N . Test the program for N = 5

Case Study – 4 N 5 i Fact 1 1 1 2 2 3 6 4 24 5 120 Start Read N Stop i = 0 i = i + 1 ? i >= N Start Fact = Fact * i No Yes Print Fact Read N N 5 Case Study – 4 i Fact 1 1 1 2 2 3 6 4 24 5 120