Reference no: EM132217501
Given a data set of up to 25 integers, determine if there is a constant value which separates every element. Display the value when it exists and the data set in sorted order.
The ouput should print exactly as the sample executions.
Example Execution #1:
Enter up to 25 values or -1 to exit: 10 8 6 4 2 16 14 12 -1
Constant value 2 separates the elements: 2 4 6 8 10 12 14 16
Example Execution #2:
Enter up to 25 values or -1 to exit: 2 4 6 8 10 1 3 5 7 9 -1 Constant value 1 separates the elements: 1 2 3 4 5 6 7 8 9 10
Example Execution #3:
Enter up to 25 values or -1 to exit: 6 16 26 36 31 21 11 -1 Constant value 5 separates the elements: 6 11 16 21 26 31 36
Example Execution #4:
Enter up to 25 values or -1 to exit: 1 2 3 4 5 10 9 8 7 -1 No constant value that separates the elements.
Example Execution #5 (-1 not needed to terminate input when 25 elements are present in the data set):
Enter up to 25 values or -1 to exit: 10 20 30 40 50 60 11 21 31 41 51 1 2 3 4 5 12 13 14 15 16 8 7 6 9 10 No constant value that separates the elements.
Example Execution #6:
Enter up to 25 values or -1 to exit: 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 -1 Constant value 1 separates the elements: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
Example Execution #7:
Enter up to 25 values or -1 to exit: 1 6 12 18 24 -1 No constant value that separates the elements.
Each example execution represents a single test of your program. Your program is expected to accept input and produce output in the same manner demonstrated above. Your program will always be tested with non-negative values that can be stored in an int variable. Do not add any "bonus" features not demonstrated in the example executions provided.
With our ability to implement user-defined functions only the following will be permitted in the main function:
Declaration of variables to be passed to functions.
Calls to user-defined functions by main.
A limited amount of control structures (see chapters 5 and 6) to retain the previous two tasks within the main
function.
Additionally, each user-defined function may represent a single task in your larger program. The failure to make a good use of user-defined functions as described here and in the course standards will result in a loss of ALL points on those assignments that require user-defined functions.