Lecture 4


Published on

basics of computers

Published in: Technology, Business
  • Be the first to comment

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

Lecture 4

  1. 1. Flow Charts
  2. 2. 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.
  3. 3. 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.
  4. 4. Flow Charts Symbols for drawing a flowchart: Start or End of the program
  5. 5. Flow Charts Symbols for drawing a flowchart: Computational Steps or Processing Function of a program
  6. 6. Flow Charts Symbols for drawing a flowchart: Input or output operation
  7. 7. Flow Charts Symbols for drawing a flowchart: Decision Making and Branching
  8. 8. Flow Charts Symbols for drawing a flowchart: Connector or joining of two parts of program
  9. 9. Flow Charts Symbols for drawing a flowchart: Magnetic Tape
  10. 10. Flow Charts Symbols for drawing a flowchart: Magnetic Disk
  11. 11. Flow Charts Symbols for drawing a flowchart: Off-page connector
  12. 12. Flow Charts Symbols for drawing a flowchart: Flow lines
  13. 13. Flow Charts Symbols for drawing a flowchart: Annotation (foot note)
  14. 14. Flow Charts Symbols for drawing a flowchart: Display
  15. 15. 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.
  16. 16. Flow Charts …Guidelines in flowcharting - • Only one flow line should come out from a process symbol. OR
  17. 17. 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.
  18. 18. Flow Charts …Guidelines in flowcharting – Only one flow line is used in conjunction with terminal symbol.
  19. 19. 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
  20. 20. 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.
  21. 21. Flow Charts Advantages Of Using Flowcharts : • Effective communication • Effective analysis • Proper documentation • Efficient Coding • Proper Debugging • Efficient Program Maintenance
  22. 22. Flow Charts Limitations of using Flowcharts : • Complex logic: Sometimes, the program logic is quite complicated. • Alterations and Modifications: Alterations may require re-drawing completely. • Reproduction: As the flowchart symbols cannot be typed, reproduction of flowchart becomes a problem.
  23. 23. Flow Charts Example 1. Draw a flowchart to find the sum of first 50 natural numbers.
  24. 24. Flow Charts Example 2 Draw a flowchart to find the largest of three numbers A,B and C.
  25. 25. Flow Charts Example 3 Draw a flowchart for computing factorial of a given number
  26. 26. Assignment Fill in the blanks- 2. A program flowchart indicates the_________ to be performed and the __________ in which they occur. 3. A program flowchart is generally read from _____________ to ________________ 4. Flowcharting symbols are connected together by means of ___________________ 5. A decision symbol may be used in determining the ____________ or ___________ of two data items. 6. __________ are used to join remote portions of a flowchart 7. ____________ connectors are used when a flowchart ends on one page and begins again on other page 8. A ________ symbol is used at the beginning and end of a flowchart. 9. The flowchart is one of the best ways of ________ a program.. 10. To construct a flowchart, one must adhere to prescribed symbols provided by the __________ . 11. The program uses a ____________ to aid it in drawing flowchart symbols.
  27. 27. Answers • Operations, sequence • Top, down • Flow line • Equality, inequality • connectors • Off -page • Terminal • documenting • ANSI (American National Standards Institute) • Flowcharting template
  28. 28. Structured English
  29. 29. 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: 6. Structured logic or instructions organized into nested or grouped procedures 7. Simple English statements such as add, multiply, move
  30. 30. Structured English Four 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.
  31. 31. The Flow of Structured English Plain Structured Pseudocode Programs English English User Analyst Programmer
  32. 32. …Structured English The conventions are used in writing structured English: • Imperative Sentences: Store the data in database. • 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.
  33. 33. …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.
  34. 34. …Structured English
  35. 35. Writing Structured English Repetition Conditions IF … THEN … DO statements … statements … ELSE UNTIL end-condition statements … END IF or or SELECT CASE 1 (conditions) DO WHILE statements … statements … CASE 2 … END DO statements … END SELECT
  36. 36. Pseudocode
  37. 37. 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.
  38. 38. …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.
  39. 39. 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