Figure 115 illustrates a flowchart with a process

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

This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Stop The logic depicted in Figure 11.4, therefore, will read the student's record, calculate the percentage marks obtained by him/her, print one line of output, and then stop. One would certainly not like to use a computer to solve a trivial problem such as this. However, if we have to compute the percentage marks obtained by several students in the same examination then we may like to take the help of a computer. The next example illustrates how to do this. Example 11.4. 50 students of a class appear in the examination of Example 11.3. Draw a flowchart for the algorithm to calculate and print the percentage marks obtained by each student along with his/her roll number and name. Solution: Since all the students have appeared in the same examination, so the process of calculation and printing the percentage marks obtained by each student will basically remain the same. The same process of reading the input data, adding the marks of all subjects, calculating the percentage, and then writing the output data has to be repeated for all the 50 students. Hence, an easy solution that comes to ones mind for this problem is to repeat the intermediate four symbols of Figure 11.4 fifty times. However if that is done, a total of 202 (50 x 4 + 2) flowchart symbols will have to be drawn. Obviously, this will be a very time consuming and tedious job and hence is not desirable. We will now see how to solve this problem in a simpler way. In a situation where the same logical steps can be repeated, the flow line symbols are used in a flowchart to indicate the repetitive nature of the logic in the form of a process loop. Figure 11.5 illustrates a flowchart with a process loop. Note the arrow head on the flow line that forms the loop. It points upward indicating that as soon as the "Write" operation is over, the control will flow back to the "Read" operation. Thus, the process loop of Figure 11.5 solves the problem of an exceedingly long flowchart by reusing the same logical steps over and over again. However,...
View Full Document

This document was uploaded on 04/07/2014.

Ask a homework question - tutors are online