• Chart the process the way it is really occurring. Do not document the way a written process or a manager thinks the process happens.
• People typically modify existing processes to enable a more efficient process. If the desired or theoretical process is charted, problems with the existing process will not be recognized and no improvements can be made.
• Test the flow chart by trying to follow the chart to perform the process charted. If there is a problem performing the operation as charted, note any differences and modify the chart to correct. A better approach would be to have someone unfamiliar with the process try to follow the flow chart and note questions or problems found.
• Include mental steps in the process such as decisions. These steps are sometimes left out because of familiarity with the process, however, represent sources of problems due to a possible lack of information used to make the decision can be inadequate or incorrect if performed by a different person.
Now, we will discuss some examples on flowcharting. These examples will help in proper understanding of flowcharting technique. This will help you in program development process in next unit of this block.
Example 1 - Design an algorithm and the corresponding flowchart for adding the test scores as given here: 26, 49, 98, 87, 62, 75
a) Algorithm
1. Start
2. Sum = 0
3. Get the first test score
4. Add first test score to sum
5. Get the second test score
6. Add to sum
7. Get the third test score
8. Add to sum
9. Get the Forth test score
10. Add to sum
11. Get the fifth test score
12. Add to sum
13. Get the sixth test score
14. Add to sum
15. Output the sum
16. Stop
b) The corresponding flowchart is as follows:
The algorithm and the flowchart here illustrate the steps for solving the problem of adding six test scores where one test score is added to sum at a time. Both the algorithm and flowchart should always have a Start step at the beginning of the algorithm or flowchart and at least one stop step at the end, or anywhere in the algorithm or flowchart.
Since we want the sum of six test score, then we should have a container for the resulting sum. In this example, the container is called sum and we make sure that sum should start with a zero value by step 2.
Example 2 - The problem with this algorithm is that, some of the steps appear more than once, i.e. step 5 get second number, step 7, get third number, etc.
One could shorten the algorithm or flowchart as follows:
a) Algorithm
1. Start
2. Sum = 0
3. Get a value
4. sum = sum + value
5. Go to step 3 to get next Value
6. Output the sum
7. Stop
b) The corresponding flowchart is as follows:
This algorithm and its corresponding flowchart are a bit shorter than the first one. In this algorithm, step 3 to 5 will be repeated, where a number is obtained and added to sum. Similarly the flowchart indicates a flowline being drawn back to the previous step indicating that the portion of the flowchart is being repeated. One problem indicates that these steps will be repeated endlessly, resulting in an endless algorithm or flowchart. The algorithm needs to be improved to eliminate this problem. In order to solve this problem, we need to add a last value to the list of numbers given. This value should be unique so that, each time we get a value, we test the value to see if we have reached the last value.
In this way our algorithm will be a finite algorithm which ends in a finite number of steps as shown below. There are many ways of making the algorithm finite.
The new list of numbers will be 26, 49, 498, 9387, 48962, 1, -1. The value –1 is a unique number since all other numbers are positive.
1. Start
2. Sum = 0
3. Get a value
4. If the value is equal to –1, go to step 7
5. Add to sum ( sum = sum + value)
6. Go to step 3 to get next Value
7. Output the sum
8. Stop