An algorithm will output the last three lines from a text file Result.txt
The lines need to be output in the same order as they appear in the file.
Assume:
- Three variables
LineX,LineYandLineZwill store the three lines. These are of type string and all three variables have been initialised to an empty string. - The file exists and contains at least three lines.
The algorithm to output the lines is expressed in eight steps.
Complete the steps.
-
Open the file ...........................................................................
-
Loop until ...........................................................................
-
........................................................................... and store in
ThisLine -
Assign
LineYtoLineX -
Assign
LineZtoLineY -
Assign
ThisLinetoLineZ -
After the loop, ...........................................................................
-
Output
LineX, LineY, LineZ
Explain the purpose of steps 4, 5 and 6 in the algorithm from part (a).






