Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

An Array Work-Out Program You are to write a program that will manipulate an array. Your program should handle up to 75 integer numbers. You

An Array Work-Out Program

You are to write a program that will manipulate an array. Your program should handle up to 75 integer numbers. You input file will be less than 75 values. You have to count how many values you read in and you cannot hard code the number of values in the data file or in your program.

Label the results for each printed output below. You will have several different outputs below. Print your results in the same order given below.

For each part below, write one or more functions (there are a number of functions). If a function returns a value, pass back the values from functions through the return statement (return value) and not through a function parameter. You are NOT to print out any answers in a function that does any calculations. Use separate print functions.

------------------------------------ 1. Read in the data elements into the array. The input is found in arrayV4.txt 2. Print out all the data elements in the array with no more than 12 numbers per output line. 3. Print out the average of the array. Averages always show at least one decimal place beyond the decimal point. A value returning function. 4. Print out how many data elements are larger than the average (one output value) and how many are smaller than the average (one output value). Pass in the average as a parameter. A value returning functions. 5. Print out the data elements in the array that are in the odd position of the array. That is printout ary[1], ary[3], ary[5] . Print only 12 numbers per line. 6. Print out the number data elements in the array that are even values in the array (one output value answer). Use the same print function as in #5 above 7. Convert every negative data element to a positive number and every positive data element to a negative number by multiplying by -1. 8. Print out the average of the new array. Use same functions above. 9. Swap the first data element in the array with the last data element in the array. Print out the array. 10. How many data elements in the array are multiples of either 7 or 13? 11. Find the largest data element and print out the data element and its array position. 12. Find the smallest data element and print out the data element and its array position. 13. How many values in the array are less than some input value (pass in the value)? You use 48 14. How many values in the array are greater than some input value (pass in the value)? You use 74. 15. How many data elements in the array are greater than one of the elements in the array (pass in the value)? (You use the 12th element so that would be ary[11]???) 16. Create a second array. Copy all the data elements from the first array to the second array. Print out the second array. You will pass to this function two arrays. 17. Now copy all the data elements from the first array to the second array in reverse order. Print out the second array. You will pass to this function two arrays. Can you write only one function for both #16 and #17? Copy( ary1, ary2, start, ending, inc)??????

Input File: arrayV4.txt

24 43 33 73 72 -3 77 23 94 -29 28 93 9 92 -8 57 -36 73 5 38 56 17 93 80 -8 99 26 72 8 4 48 21 54 -23 84 32 97 4 38 35 -45 57 64 7 44 26 45 66 57 -22 62 52 -7 -36 62 78 -67 34 73 93 8 -3 -2 2 35 1 11 12 -73 57 77 -74 37

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions