LAB 304 Final. Lecture \ 4 Lecture \ 4 _ المحاضرة 4 بالكامل.
Lecture 4
-
Upload
anshumali-singh -
Category
Technology
-
view
17.531 -
download
0
description
Transcript of Lecture 4
![Page 1: Lecture 4](https://reader033.fdocuments.us/reader033/viewer/2022060110/555a5f9fd8b42ae7218b462d/html5/thumbnails/1.jpg)
Flow Charts
![Page 2: Lecture 4](https://reader033.fdocuments.us/reader033/viewer/2022060110/555a5f9fd8b42ae7218b462d/html5/thumbnails/2.jpg)
Flow Charts •A diagrammatic representation that illustrates the sequence of operations to be performed to get the solution of a problem.• Generally drawn in the early stages of formulating computer solutions. • Facilitate communication between programmers and business people. • 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. • Must for the better documentation of a complex program.
![Page 3: Lecture 4](https://reader033.fdocuments.us/reader033/viewer/2022060110/555a5f9fd8b42ae7218b462d/html5/thumbnails/3.jpg)
Flow Charts
A flow chart can be used to:
• Define and analyse processes.
• Build a step-by-step picture of the process for analysis, discussion, or communication.
• Define, standardise or find areas for improvement in a process.
![Page 4: Lecture 4](https://reader033.fdocuments.us/reader033/viewer/2022060110/555a5f9fd8b42ae7218b462d/html5/thumbnails/4.jpg)
Flow Charts
Symbols for drawing a flowchart:
Start or End of the program
![Page 5: Lecture 4](https://reader033.fdocuments.us/reader033/viewer/2022060110/555a5f9fd8b42ae7218b462d/html5/thumbnails/5.jpg)
Flow Charts
Symbols for drawing a flowchart:
Computational Steps or Processing Function of a program
![Page 6: Lecture 4](https://reader033.fdocuments.us/reader033/viewer/2022060110/555a5f9fd8b42ae7218b462d/html5/thumbnails/6.jpg)
Flow Charts
Symbols for drawing a flowchart:
Input or output operation
![Page 7: Lecture 4](https://reader033.fdocuments.us/reader033/viewer/2022060110/555a5f9fd8b42ae7218b462d/html5/thumbnails/7.jpg)
Flow Charts
Symbols for drawing a flowchart:
Decision Making and Branching
![Page 8: Lecture 4](https://reader033.fdocuments.us/reader033/viewer/2022060110/555a5f9fd8b42ae7218b462d/html5/thumbnails/8.jpg)
Flow Charts
Symbols for drawing a flowchart:
Connector or joining of two parts of program
![Page 9: Lecture 4](https://reader033.fdocuments.us/reader033/viewer/2022060110/555a5f9fd8b42ae7218b462d/html5/thumbnails/9.jpg)
Flow Charts
Symbols for drawing a flowchart:
Magnetic Tape
![Page 10: Lecture 4](https://reader033.fdocuments.us/reader033/viewer/2022060110/555a5f9fd8b42ae7218b462d/html5/thumbnails/10.jpg)
Flow Charts
Symbols for drawing a flowchart:
Magnetic Disk
![Page 11: Lecture 4](https://reader033.fdocuments.us/reader033/viewer/2022060110/555a5f9fd8b42ae7218b462d/html5/thumbnails/11.jpg)
Flow Charts
Symbols for drawing a flowchart:
Off-page connector
![Page 12: Lecture 4](https://reader033.fdocuments.us/reader033/viewer/2022060110/555a5f9fd8b42ae7218b462d/html5/thumbnails/12.jpg)
Flow Charts
Symbols for drawing a flowchart:
Flow lines
![Page 13: Lecture 4](https://reader033.fdocuments.us/reader033/viewer/2022060110/555a5f9fd8b42ae7218b462d/html5/thumbnails/13.jpg)
Flow Charts
Symbols for drawing a flowchart:
Annotation (foot note)
![Page 14: Lecture 4](https://reader033.fdocuments.us/reader033/viewer/2022060110/555a5f9fd8b42ae7218b462d/html5/thumbnails/14.jpg)
Flow Charts
Symbols for drawing a flowchart:
Display
![Page 15: Lecture 4](https://reader033.fdocuments.us/reader033/viewer/2022060110/555a5f9fd8b42ae7218b462d/html5/thumbnails/15.jpg)
Flow Charts
Guidelines in flowcharting - • 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.
![Page 16: Lecture 4](https://reader033.fdocuments.us/reader033/viewer/2022060110/555a5f9fd8b42ae7218b462d/html5/thumbnails/16.jpg)
Flow Charts
…Guidelines in flowcharting -
• Only one flow line should come out from a process symbol.
OR
![Page 17: Lecture 4](https://reader033.fdocuments.us/reader033/viewer/2022060110/555a5f9fd8b42ae7218b462d/html5/thumbnails/17.jpg)
Flow Charts
…Guidelines in flowcharting -
• 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.
![Page 18: Lecture 4](https://reader033.fdocuments.us/reader033/viewer/2022060110/555a5f9fd8b42ae7218b462d/html5/thumbnails/18.jpg)
Flow Charts
…Guidelines in flowcharting –
Only one flow line is used in conjunction with terminal symbol.
![Page 19: Lecture 4](https://reader033.fdocuments.us/reader033/viewer/2022060110/555a5f9fd8b42ae7218b462d/html5/thumbnails/19.jpg)
Flow Charts
…Guidelines in flowcharting –
Write within standard symbols briefly. As necessary, you can use the annotation symbol to describe data or computational steps more clearly.
This is confidential data
![Page 20: Lecture 4](https://reader033.fdocuments.us/reader033/viewer/2022060110/555a5f9fd8b42ae7218b462d/html5/thumbnails/20.jpg)
Flow Charts
…Guidelines in flowcharting –
• In case of complex flowchart, it is better to use connector symbols to reduce the number of flow lines. Avoid the intersection of flow lines.
• 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.
![Page 21: Lecture 4](https://reader033.fdocuments.us/reader033/viewer/2022060110/555a5f9fd8b42ae7218b462d/html5/thumbnails/21.jpg)
Flow Charts
Advantages Of Using Flowcharts :
• Effective communication• Effective analysis• Proper documentation• Efficient Coding• Proper Debugging• Efficient Program Maintenance
![Page 22: Lecture 4](https://reader033.fdocuments.us/reader033/viewer/2022060110/555a5f9fd8b42ae7218b462d/html5/thumbnails/22.jpg)
Flow Charts
Limitations of using Flowcharts :
1.Complex logic: Sometimes, the program logic is quite complicated.
2.Alterations and Modifications: Alterations may require re-drawing completely.
3.Reproduction: As the flowchart symbols cannot be typed, reproduction of flowchart becomes a problem.
![Page 23: Lecture 4](https://reader033.fdocuments.us/reader033/viewer/2022060110/555a5f9fd8b42ae7218b462d/html5/thumbnails/23.jpg)
Flow Charts
Example 1.
Draw a flowchart to find the sum of first 50 natural numbers.
![Page 24: Lecture 4](https://reader033.fdocuments.us/reader033/viewer/2022060110/555a5f9fd8b42ae7218b462d/html5/thumbnails/24.jpg)
![Page 25: Lecture 4](https://reader033.fdocuments.us/reader033/viewer/2022060110/555a5f9fd8b42ae7218b462d/html5/thumbnails/25.jpg)
Example 2
Draw a flowchart to find the largest of three numbers A,B and C.
Flow Charts
![Page 26: Lecture 4](https://reader033.fdocuments.us/reader033/viewer/2022060110/555a5f9fd8b42ae7218b462d/html5/thumbnails/26.jpg)
![Page 27: Lecture 4](https://reader033.fdocuments.us/reader033/viewer/2022060110/555a5f9fd8b42ae7218b462d/html5/thumbnails/27.jpg)
Example 3Draw a flowchart for computing factorial of a given number
Flow Charts
![Page 28: Lecture 4](https://reader033.fdocuments.us/reader033/viewer/2022060110/555a5f9fd8b42ae7218b462d/html5/thumbnails/28.jpg)
![Page 29: Lecture 4](https://reader033.fdocuments.us/reader033/viewer/2022060110/555a5f9fd8b42ae7218b462d/html5/thumbnails/29.jpg)
AssignmentFill in the blanks- 1. A program flowchart indicates the_________ to be performed
and the __________ in which they occur. 2. A program flowchart is generally read from _____________ to
________________ 3. Flowcharting symbols are connected together by means of
___________________ 4. A decision symbol may be used in determining the
____________ or ___________ of two data items. 5. __________ are used to join remote portions of a flowchart 6. ____________ connectors are used when a flowchart ends on
one page and begins again on other page 7. A ________ symbol is used at the beginning and end of a
flowchart. 8. The flowchart is one of the best ways of ________ a program.. 9. To construct a flowchart, one must adhere to prescribed
symbols provided by the __________ . 10.The program uses a ____________ to aid it in drawing
flowchart symbols.
![Page 30: Lecture 4](https://reader033.fdocuments.us/reader033/viewer/2022060110/555a5f9fd8b42ae7218b462d/html5/thumbnails/30.jpg)
Answers
• Operations, sequence • Top, down • Flow line • Equality, inequality • connectors • Off -page • Terminal • documenting • ANSI (American National Standards Institute) • Flowcharting template
![Page 31: Lecture 4](https://reader033.fdocuments.us/reader033/viewer/2022060110/555a5f9fd8b42ae7218b462d/html5/thumbnails/31.jpg)
Structured English
![Page 32: Lecture 4](https://reader033.fdocuments.us/reader033/viewer/2022060110/555a5f9fd8b42ae7218b462d/html5/thumbnails/32.jpg)
Structured English• Structured English is a tool used to
represent process logic. • Syntax rules are not very strict & an English
statement is used to specify an action. • The main aim is to allow easy readability,
which helps in documentation.
Two building blocks of Structured English:1. Structured logic or instructions organized
into nested or grouped procedures 2. Simple English statements such as add,
multiply, move
![Page 33: Lecture 4](https://reader033.fdocuments.us/reader033/viewer/2022060110/555a5f9fd8b42ae7218b462d/html5/thumbnails/33.jpg)
Structured EnglishFour conventions to follow when using Structured
English:
• Express all logic in terms of sequential structures, decision structures, or iterations.
• Use upper case for keywords such as: IF, THEN, ELSE, DO, DO WHILE, DO UNTIL, PERFORM
• Indent blocks of statements to show their hierarchy (nesting) clearly.
• When words or phrases have been defined, underline those words or phrases to indicate that they have a specialised, reserved meaning.
![Page 34: Lecture 4](https://reader033.fdocuments.us/reader033/viewer/2022060110/555a5f9fd8b42ae7218b462d/html5/thumbnails/34.jpg)
The Flow of Structured English
User
Structured English
Analyst
Programs
Programmer
Plain Englis
h
Pseudocode
![Page 35: Lecture 4](https://reader033.fdocuments.us/reader033/viewer/2022060110/555a5f9fd8b42ae7218b462d/html5/thumbnails/35.jpg)
…Structured English
The conventions are used in writing structured English:
1. Imperative Sentences: Store the data in database.
2. Arithmetic & Relational Operations : Common symbols of mathematics are used in structured English such as- + for add, - for subtraction etc. and =, >=, != etc. are used for relational operations.
![Page 36: Lecture 4](https://reader033.fdocuments.us/reader033/viewer/2022060110/555a5f9fd8b42ae7218b462d/html5/thumbnails/36.jpg)
…Structured English
3. Decision Structures: If Then Else, Select Case
4. Repetion: Loops
There are various forms in which structured english can be implemented to solve the problem. e.g. Algorithm, Flowchart, pseudocode.
![Page 37: Lecture 4](https://reader033.fdocuments.us/reader033/viewer/2022060110/555a5f9fd8b42ae7218b462d/html5/thumbnails/37.jpg)
…Structured English
![Page 38: Lecture 4](https://reader033.fdocuments.us/reader033/viewer/2022060110/555a5f9fd8b42ae7218b462d/html5/thumbnails/38.jpg)
Writing Structured EnglishRepetition
DO
statements …
UNTIL end-condition
or
DO WHILE
statements …
END DO
Conditions
IF … THEN …
statements …
ELSE
statements …
END IF
or
SELECT CASE 1 (conditions)
statements …
CASE 2 …
statements …
END SELECT
![Page 39: Lecture 4](https://reader033.fdocuments.us/reader033/viewer/2022060110/555a5f9fd8b42ae7218b462d/html5/thumbnails/39.jpg)
Pseudocode
![Page 40: Lecture 4](https://reader033.fdocuments.us/reader033/viewer/2022060110/555a5f9fd8b42ae7218b462d/html5/thumbnails/40.jpg)
Pseudocode
• An outline of a program, written in a form that can easily be converted into real programming statements.
• Pseudocode cannot be compiled nor executed, and there are no real formatting or syntax rules.
![Page 41: Lecture 4](https://reader033.fdocuments.us/reader033/viewer/2022060110/555a5f9fd8b42ae7218b462d/html5/thumbnails/41.jpg)
…Pseudocode
• It enables the programmer to concentrate on the algorithms without worrying about all the syntactic details of a particular programming language.
• Flowcharts can be thought of as a graphical form of pseudocode.
![Page 42: Lecture 4](https://reader033.fdocuments.us/reader033/viewer/2022060110/555a5f9fd8b42ae7218b462d/html5/thumbnails/42.jpg)
Example of Pseudocode
Regular code (written in PHP):<?php if (is_valid($cc_number)) { execute_transaction($cc_number, $order); } else { show_failure(); } ?> Pseudocode:if credit card number is valid
execute transaction based on number and order else show a generic failure message end if