Introduction to Flowcharts

4,603 views
4,164 views

Published on

Published in: Education, Business, Technology
0 Comments
5 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
4,603
On SlideShare
0
From Embeds
0
Number of Embeds
11
Actions
Shares
0
Downloads
165
Comments
0
Likes
5
Embeds 0
No embeds

No notes for slide

Introduction to Flowcharts

  1. 1. Flow Charting Damian Gordon
  2. 2. Introduction• We mentioned it already, that if we thing of an analyst as being analogous to an architect, and a developer as being analogous to a builder, then the most important thing we can do as analysts is to explain our designs to the developers in a simple and clear way.• How do architects do this?
  3. 3. Flowcharts• So let’s say we want to express the following algorithm: – Read in a number and print it out.
  4. 4. START
  5. 5. STARTRead in A
  6. 6. STARTRead in A Print A
  7. 7. STARTRead in A Print A END
  8. 8. Flowcharts• So let’s say we want to express the following algorithm: – Read in a number and print it out double the number.
  9. 9. START
  10. 10. STARTRead in A
  11. 11. STARTRead in APrint A*2
  12. 12. STARTRead in APrint A*2 END
  13. 13. Or alternatively...
  14. 14. START
  15. 15. STARTRead in A
  16. 16. STARTRead in AB = A*2
  17. 17. STARTRead in A B=A*2 can beB = A*2 read as “B gets the value of A multiplied by 2”
  18. 18. STARTRead in AB = A*2 Print B
  19. 19. STARTRead in AB = A*2 Print B END
  20. 20. Flowcharts• So let’s say we want to express the following algorithm: – Read in a number, check if it is odd or even.
  21. 21. START
  22. 22. STARTRead in A
  23. 23. STARTRead in A Does A/2 give aremainder?
  24. 24. START Read in A Does A/2Print “It’s Odd” Yes give a remainder?
  25. 25. START Read in A Does A/2 NoPrint “It’s Odd” Yes Print “It’s Even” give a remainder?
  26. 26. START Read in A Does A/2 NoPrint “It’s Odd” Yes Print “It’s Even” give a remainder? END
  27. 27. Flowcharts• So let’s say we want to express the following algorithm to print out the bigger of two numbers: – Read in two numbers, call them A and B. Is A is bigger than B, print out A, otherwise print out B.
  28. 28. START
  29. 29. STARTRead in A and B
  30. 30. STARTRead in A and B A>B?
  31. 31. START Read in A and BPrint A Yes A>B?
  32. 32. START Read in A and B Yes NoPrint A A>B? Print B
  33. 33. START Read in A and B Yes NoPrint A A>B? Print B END
  34. 34. Flowcharts• So let’s say we want to express the following algorithm to print out the bigger of three numbers: – Read in three numbers, call them A, B and C. • If A is bigger than B, then if A is bigger than C, print out A, otherwise print out C. • If B is bigger than A, then if B is bigger than C, print out B, otherwise print out C.
  35. 35. START
  36. 36. STARTRead in A, B and C
  37. 37. STARTRead in A, B and C A>B?
  38. 38. START Read in A, B and C YesA>C? A>B?
  39. 39. START Read in A, B and C Yes NoA>C? A>B? B>C?
  40. 40. START Read in A, B and C Yes NoA>C? A>B? B>C? No No Print C
  41. 41. START Read in A, B and CYes Yes No A>C? A>B? B>C? No No Print A Print C
  42. 42. START Read in A, B and CYes Yes No Yes A>C? A>B? B>C? No No Print A Print C Print B
  43. 43. START Read in A, B and CYes Yes No Yes A>C? A>B? B>C? No No Print A Print C Print B END
  44. 44. Flowcharts• So let’s say we want to express the following algorithm: – Print out the numbers from 1 to 5
  45. 45. START
  46. 46. STARTPrint 1
  47. 47. STARTPrint 1Print 2
  48. 48. STARTPrint 1Print 2Print 3
  49. 49. STARTPrint 1Print 2Print 3Print 4
  50. 50. STARTPrint 1Print 2Print 3Print 4Print 5
  51. 51. STARTPrint 1Print 2Print 3Print 4Print 5 END
  52. 52. Or alternatively...
  53. 53. Flowcharts A=A+1• If I say A = A + 1, that means “A gets the value of whatever is in itself, plus 1”• If A is 14• It becomes 15 14 +1 A (old) 15 A (new)
  54. 54. START
  55. 55. STARTA=1
  56. 56. START A=1Is A==6?
  57. 57. START A=1 NoIs A==6? Print A
  58. 58. START A=1 A=A+1 NoIs A==6? Print A
  59. 59. START A=1 A=A+1 NoIs A==6? Print A
  60. 60. START A=1 A=A+1 NoIs A==6? Print AYes END
  61. 61. Flowcharts• So let’s say we want to express the following algorithm: – Add up the numbers 1 to 5
  62. 62. Flowcharts T=5• But first a few points;• If I say T = 5, that means “T gets the value 5”
  63. 63. Flowcharts T=5• But first a few points;• If I say T = 5, that means “T gets the value 5” T
  64. 64. Flowcharts T=5• But first a few points;• If I say T = 5, that means “T gets the value 5” 5 T
  65. 65. Flowcharts T=X• If I say T = X, that means “T gets the value of whatever is in the variable X”
  66. 66. Flowcharts T=X• If I say T = X, that means “T gets the value of whatever is in the variable X”• So if X is 14, then T will get the value 14.
  67. 67. Flowcharts T=X• If I say T = X, that means “T gets the value of whatever is in the variable X”• So if X is 14, then T will get the value 14. 14 X 14 T
  68. 68. Flowcharts T=X+1• If I say T = X+1, that means “T gets the value of whatever is in the variable X plus one”
  69. 69. Flowcharts T=X+1• If I say T = X+1, that means “T gets the value of whatever is in the variable X plus one”• So if X is 14, T becomes 15, and X stays as 14.
  70. 70. Flowcharts T=X+1• If I say T = X+1, that means “T gets the value of whatever is in the variable X plus one”• So if X is 14, T becomes 15, and X stays as 14. +1 14 X 15 T
  71. 71. Flowcharts T=T+X• If I say T = T + X, that means “T gets the value of whatever is in itself plus whatever is in the variable X”
  72. 72. Flowcharts T=T+X• If I say T = T + X, that means “T gets the value of whatever is in itself plus whatever is in the variable X”• If T is 14 and X is 9• T becomes 23• X stays at 9
  73. 73. Flowcharts T=T+X• If I say T = T + X, that means “T gets the value of whatever is in itself plus whatever is in the variable X”• If T is 14 and X is 9• T becomes 23 14 9• X stays at 9 T(old) X 23 T(new)
  74. 74. Flowcharts• So let’s say we want to express the following algorithm: – Add up the numbers 1 to 5
  75. 75. START
  76. 76. STARTTotal = 0
  77. 77. STARTTotal = 0 A=1
  78. 78. STARTTotal = 0 A=1Is A==6?
  79. 79. STARTTotal = 0 A=1 NoIs A==6? Total = Total + A;
  80. 80. STARTTotal = 0 A=1 A=A+1 NoIs A==6? Total = Total + A;
  81. 81. STARTTotal = 0 A=1 A=A+1 NoIs A==6? Total = Total + A;Yes END
  82. 82. Flowcharts• So let’s say we want to express the following algorithm: – Read in a number and check if it’s a prime number.
  83. 83. Flowcharts• So let’s say we want to express the following algorithm: – Read in a number and check if it’s a prime number. – What’s a prime number?
  84. 84. Flowcharts• So let’s say we want to express the following algorithm: – Read in a number and check if it’s a prime number. – What’s a prime number? – A number that’s only divisible by itself and 1, e.g. 7.
  85. 85. Flowcharts• So let’s say we want to express the following algorithm: – Read in a number and check if it’s a prime number. – What’s a prime number? – A number that’s only divisible by itself and 1, e.g. 7. – Or to put it another way, every number other than itself and 1 gives a remainder, e.g. For 7, if 6, 5, 4, 3, and 2 give a remainder then 7 is prime.
  86. 86. Flowcharts• So let’s say we want to express the following algorithm: – Read in a number and check if it’s a prime number. – What’s a prime number? – A number that’s only divisible by itself and 1, e.g. 7. – Or to put it another way, every number other than itself and 1 gives a remainder, e.g. For 7, if 6, 5, 4, 3, and 2 give a remainder then 7 is prime. – So all we need to do is divide 7 by all numbers less than it but greater than one, and if any of them have no remainder, we know it’s not prime.
  87. 87. Flowcharts• So,• If the number is 7, as long as 6, 5, 4, 3, and 2 give a remainder, 7 is prime.• If the number is 9, we know that 8, 7, 6, 5, and 4, all give remainders, but 3 does not give a remainder, it goes evenly into 9 so we can say 9 is not prime
  88. 88. Flowcharts• So remember, – if the number is 7, as long as 6, 5, 4, 3, and 2 give a remainder, 7 is prime.• So, in general, – if the number is A, as long as A-1, A-2, A-3, A- 4, ... 2 give a remainder, A is prime.
  89. 89. START
  90. 90. STARTRead in A
  91. 91. STARTRead in AB = A -1
  92. 92. STARTRead in AB = A -1Is B = = 1?
  93. 93. START Read in A B = A -1No Is B = = 1?
  94. 94. START Read in A B = A -1 No Is B = = 1? Does A/B give aremainder?
  95. 95. START Read in A B = A -1 No Is B = = 1?Yes Does A/B give a remainder?
  96. 96. START Read in A B = A -1B=B-1 No Is B = = 1? Yes Does A/B give a remainder?
  97. 97. START Read in A B = A -1B=B-1 No Is B = = 1? Yes Does A/B give a remainder?
  98. 98. START Read in A B = A -1B=B-1 No Is B = = 1? Yes Does A/B give a remainder? No Print “Not Prime”
  99. 99. START Read in A B = A -1B=B-1 No Yes Is B = = 1? Print “Prime” Yes Does A/B give a remainder? No Print “Not Prime”
  100. 100. START Read in A B = A -1B=B-1 No Yes Is B = = 1? Print “Prime” Yes Does A/B give a remainder? No Print “Not Prime” END
  101. 101. Symbols
  102. 102. Symbols
  103. 103. Symbols Terminal DecisionInput/OutputOperation Connector Process Module

×