Question: Write a C console application that determines whether a data stream is sorted in ascending order. A data stream can be either keyboard or a
Write a C console application that determines whether a data stream is sorted in ascending order. A data stream can be either keyboard or a file. The interface for the program is a command shell's command line.
Requirements
The program must handle any length of list so your program must work in a 64-bit build. The list will be input from the console or read from a file. This is terminated with end-of-stream ^Z on windows.
The output must indicate if the data sorted by printing the single word 'sorted' on a single line, then return the integer value 101 from the main. if the stream is not sorted, you are to print "element # (Value) not sorted where # is the offset of the first out-of-order element and value is the value of the unsorted element. In the unsorted case, main must return the integer 100.
Failure to complete the test (bad input, filename, switch) for any reason and the main should return; EXIT_FAILURE
If help was selected, main should return EXIT_SUCCESS.
The command line arguments below.
That is what it should look like if the user enters -help or --help.
Note
1. Expected you perform input with getchar() and scanf().
2. Not required to validate that every number test for the negative sign if reading natural numbers.
3. Should report if the user entered an invalid switch (e.g., -x)
The green, blue and yellow items are necessary requirements, but the red items below can not be included.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
