Problem description

Your program will analyze up to 100 integers stored in an array. The data are contained in a text file. Your program must use input redirection to read the file.

Your program should start with a function to read the data file and fill the array. Note that the file size is unspecified: there may be fewer than 100 numbers, exactly 100 numbers, or more than 100 numbers in the input file. If there are fewer than 100 numbers in the file, the read function must return the index for the last element used in the array. If there are more than 100 integers in the file, the read function must return when the array reaches capacity.

In building the array, if the number is evenly divisible by 3 or 7, store it as a negative number.

Next, implement a function for each of the following:

a. Print the array ten values to a line. Make sure that the values are aligned in rows.
b. Print the odd values, ten to a line.
c. Print the values at the odd-numbered index locations, ten to a line.
d. Return a count of the number of even values. Zero is an even number.
e. Return the sum of all values in the array.
f. Return the location of the smallest value in the array.
g. Return the location of the largest value in the array.
h. Copy all positive values to a new array. Then use process (a) above to print the new array.
i. Copy all negative values to a new array. Then use process (a) above to print the new array.
j. Print the array using process (a) above.
k. Sort the array using the selection sort algorithm. Then use process (a) above to print the array.

Demonstrate each of the functions in the order shown above.

Notes:

  • Declare arrays with a named constant.
  • Array functions require as parameters, at a minimum, the array and its length.
  • Array functions may not rely upon global constants to determine the length of an array parameter. You may use a global constant to declare arrays local to the function.
  • There are 80 characters in a line.
  • Write additional functions as necessary to support your implementation. Remember: functions should do only one (typically small) thing, no more. Its combining these general-purpose functions that give us the greatest flexibility and reusability.
Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.