Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

You are to write a program that will manipulate an array. Your program should handle up to 50 integer numbers. You input file will be

You are to write a program that will manipulate an array. Your program should handle up to 50 integer numbers. You input file will be less than 50 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 out 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). Pass back the values from functions through the return statement (return value) and not through a function parameter.

------------------------------------

1. Read in the data elements into the array. The input is found in arrayV2.dat

2. Print out all the data elements in the array with no more than 10 numbers per output line.

3. Print out the average of the array.

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.

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 10 numbers per line.

6. Print out the number data elements in the array that are even values in the array (one output value answer).

7. Convert every negative data element to a positive number and every positive data element to a negative number.

8. Print out the average of the new array.

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 11?

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 31?

14. How many values in the array are greater than 80?

15. How many data elements in the array are greater than the 29th data element in the array? (That would be ary[28]???)

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.

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

Step: 3

blur-text-image

Ace Your Homework with AI

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

Get Started

Recommended Textbook for

Essential SQLAlchemy Mapping Python To Databases

Authors: Myers, Jason Myers

2nd Edition

1491916567, 9781491916568

More Books

Students also viewed these Databases questions