Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

write two functions. One function will locate and returnthe largest value in an integer array. The second function will loop through the integer array, check

write two functions. One function will locate and return the largest value in an integer array. The second function will loop through the integer array, check each value to see if it is even or odd and place the appropriate word in a corresponding string array. Finally, your program will loop through the two arrays, printing the integer value from the integer array followed by the string value from the string array in the same item position.

Requirements

  1. Define an integer array that will hold 10 integers. Initialize it with the following values: 56, 77, 23, 12, 88, 59, 97, 33, 38, 64.
  2. Define a string array that will hold 10 strings.
  3. Write a function, named findMax, that will accept two arguments and return an integer value. The first parameter is an integer array. The second parameter is the size or length of the integer array. Loop through the positions in the array, searching all items to find the largest value in the array. Return the array index of the largest value found.
  4. Write a function named, evenOrOdd, that will accept three parameters. The first parameter is the integer array used in the above function. The second parameter is the string array from step 2 and the third parameter is an integer indicating the size of the two arrays. This function will perform the following tasks:
  5.  
    1. This function will loop through the first array, checking each value to see if it is even or odd.
    2. For each item in the integer array, the function will then place the appropriate value, "even" or "odd", in the corresponding position of the string array.

Hint: Using the modulus operator, (also called the modulo), to divide the number by 2 will result in either a remainder of 0 or 1. A remainder of 0 indicates an even number and a remainder of 1 indicates an odd number. The modulus operator for all of the languages in this class is %.

For more on the modulus/remainder operator check out:

3.7 Arithmetic in C# for Programmers text

2.6 Arithmetic in Java for Programmers text

6.6 Arithmetic (page 201) in Internet & WorldWideWeb

  1. After calling both functions, print the maximum number determined by findMax as well as the array index position of the largest number. Next, the program will loop through the two arrays and print the integer from integer array followed by the corresponding "even" or "odd" value from the string array.

EXPECTED OUTPUT

The largest number in the array is 97 located at array index 6.

The numbers were:

56 is even

77 is odd

23 is odd

12 is even

88 is even

59 is odd

97 is odd

33 is odd

38 is even

64 is even

Step by Step Solution

There are 3 Steps involved in it

Step: 1

Below is an example of a program in Python that fulfills the specified requirements findMaxarr maxval arr0 maxindex 0 for i in range1 lenarr if arri m... 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

Computer Systems A Programmers Perspective

Authors: Randal E. Bryant, David R. O'Hallaron

3rd Global Edition

1292101768, 978-1292101767

More Books

Students also viewed these Programming questions