supposed you had some data coming into the program which is organized like this. student name grade grade grade ENDS student name grade grade ENDS student name grade grade grade grade ENDS END you need to produce each student's average grade, and then report a count how many students were processed. You don't know how many students, or how many grades for each student. ENDS ends one student, END ends the whole problem. first think about processing one student read in name initialize grade total initialize grade counter read in grade while grade is not ENDS add grade to accumulator read in another grade add one to a counter for grades (note that this work is OUTSIDE the loop, it only does its job one time!) if counter for grades > 0 average = total / grade counter otherwise average is zero report name and average, processed 1 student ----------------------------------- now throw another loop around that to handle all the students initialize student counter read in name while name is not END initialize grade total initialize grade counter read in grade while grade is not ENDS add grade to accumulator read in another grade add one to a counter for grades if counter for grades > 0 average = total / counter otherwise average is zero report name and average add one to student counter read in name report student counter