3 we want to make a list of only those students who

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: record whose sole purpose is to indicate that the end of the input data has been reached. Suppose the first 7 characters of the input record represents a student's roll number (Rollno). Since 0000000 is never used as a roll number, a value of 0000000 as the first 7 characters can be used to represent the trailer record. As each input record is processed, the Rollno can be compared with 0000000 to determine if processing is complete. The logic of this process is illustrated in the flowchart of Figure 11.7. It is important to recognize that the programmer would have to include instructions in the program, which specifically compare the Rollno to 0000000 in order to determine whether to continue or to terminate. Start Count = 0 Read input data Add marks of all subjects giving Total Percentage = Total I 10 Write output data Add1 to Count Is count = 50? Yes Stop If no Read input data The concept of a trailer record centers around the notion of selecting a field (a particular item of data) in the input record which will be used to indicate the end of data and then selecting a trailer value also known as sentinel value which will never occur as normal data value for that field. The roll number of 0000000 is a good example. It may also be noted that when a trailer record is used to mark the end of input data, the decision box used for checking the trailer value should almost always be flowcharted immediately after the input symbol. Start Read input data Is Rollno = 0000000? If yes than Stop If no Add marks of all subjects giving Total Percentage = Total/10 Write output data Read input data Example 11.5. For the examination of Example 11.3, we want to make a list of only those students who have passed obtained 30% or more marks) in the examination. In the end, we also want to print out the total number of students who have passed. Assuming that the input data of all the students is terminated by a trailer record that has sentinel value of 9999999 for Rollno, draw a flowchart for the algorithm to do the above job. Solution: The flow...
View Full Document

This document was uploaded on 04/07/2014.

Ask a homework question - tutors are online