Access over 20 million homework & study documents

3 Write a program called tail c that prints out the last N lines of

Content type
User Generated
Rating
Showing Page:
1/2
3. Write a program called tail.c that prints out the last N
lines of a given file 1. Name your executable tail.out 2.
Arguments to your program will be passed on the
command line in the following order 1. Name of the file 2.
N 3. N will always be at least 1 4. If N is greater than the
number of lines in the file, all of the lines in the file should
be displayed 5. You may assume that no line is longer than
100 characters 1. For an additional challenge try to solve
the problem where there is no limit on the length of a line
1. My solution to dealing with any length lines involved
using the functions ftell and fseek. 6. There is no limit to
the number of lines in a file 7. Some lines may only contain
the newline character, these still count as a line 8. My
editor automatically added 1 newline character to the end
of most of the test files but does not display them. Your
editor may or may not display them but do be aware that
they are there. Example. Assume the file meme.txt
contains the following It is over 9000!!! 1../tail.out
meme.txt 1 over 9000!!! 2../tail.out meme.txt 2 is over
9000!!! 3../tail.out meme.txt 10 It is over 9000!!!
Solution
public class CoinToss { private enum Coin{Heads, Tails};
Random randomNum = new Random(); private int result =
randomNum.nextInt(2); private int heads = 0; private int
tails = 1; Coin coinFlip; public void flip(){ if(result == 0){
coinFlip = Coin.Heads; System.out.println(\"You

Sign up to view the full document!

lock_open Sign Up
Showing Page:
2/2

Sign up to view the full document!

lock_open Sign Up
Unformatted Attachment Preview
3. Write a program called tail.c that prints out the last N lines of a given file 1. Name your executable tail.out 2. Arguments to your program will be passed on the command line in the following order 1. Name of the file 2. N 3. N will always be at least 1 4. If N is greater than the number of lines in the file, all of the lines in the file should be displayed 5. You may assume that no line is longer than 100 characters 1. For an additional challenge try to solve the problem where there is no limit o n the length of a line 1. My solution to dealing with any length lines involved using the fun ...
Purchase document to see full attachment
User generated content is uploaded by users for the purposes of learning and should be used following Studypool's honor code & terms of service.

Anonymous
Really useful study material!

Studypool
4.7
Trustpilot
4.5
Sitejabber
4.4