Suppose the examination of example 113 is a

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: the flowchart of Figure 11.5 is incomplete because the process loop has introduced a new problem. The process loop shown does not have a logical ending. It will continue to attempt to repeat those four steps until someone manually cancels the job. This is an example of an infinite loop and hence the flowchart of Figure 11.5 does not represent an algorithm because an algorithm must terminate. So we have to find out a way of terminating the algorithm. This is done by the use of a decision symbol. Figure 11.6 shows a flowchart, which uses a decision step to terminate the algorithm. In this flowchart, another variable Count has been introduced which is initialized to zero outside the process loop and is incremented by 1 after processing the data for each student. Thus, the value of Count will always be equal to the number of students whose data has already been processed. At the decision step, the value of Count is compared with 50, which is the total number of students who have appeared for the examination. The steps within the process loop are repeated until the value of Count becomes equal to 50, the instruction at the decision step causes the control to flow out of the loop and the processing stops because a terminal symbol labeled Stop is encountered. Thus, the flowchart of Figure 11.6 is a complete and correct solution to the problem of Example 11.4. Although the flowchart of Figure 11.6 is a correct solution to the given problem, it suffers from two major drawbacks. The first drawback is that in order to make the decision at the decision step, one must know the exact number of students who appeared in the examination. Suppose the examination of Example 11.3 is a university examination in which the total number of students who appeared for the examination is too large (say more than ten thousand). In such a situation, the counting of the total number of input records (data for each student) becomes a tedious job. Even then, if we do stick on counting the input records manually and supply the number of records to be compared against Count in the decision box and suppose while...
View Full Document

This document was uploaded on 04/07/2014.

Ask a homework question - tutors are online