Printing last K lines from a file
Given a large file containing many lines of text, How do we write an efficient program to print last k lines from that file. One obvious approach is to read the entire file first to find the number of lines (n). In the second iteration skip first (n-k) lines, and print the remaining k lines. …