1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
guajiro [1.7K]
3 years ago
10

Write a recursive, int-valued method named productOfOdds that accepts an integer array, and the number of elements in the array

and returns the product of the odd-valued elements of the array. You may assume the array has at least one odd-valued element. The product of the odd-valued elements of an integer-valued array recursively may be calculated as follows: If the array has a single element and it is odd, return the value of that element; otherwise return 1. Otherwise, if the first element of the array is odd, return the product of that element and the result of finding the product of the odd elements of the rest of the array; if the first element is NOT odd, simply return the result of finding the product of the odd elements of the rest of the array
Computers and Technology
1 answer:
lara [203]3 years ago
4 0

Answer:

Program source code found in explaination

Explanation:

Recursive int function of the asked question.;

int productOfOdds(int array[],int length) {

int product=1;

if(length==0)

return -1;

else if(length==1) {

if(array[length-1]%2!=0)

return array[length-1];

else

return 1;

}

else {

product=productOfOdds(array,--length);

if(array[length]%2!=0) {

product=product*array[length];

}

}

return product;

}

You might be interested in
Identify the false statement.
Lelechka [254]
A is   false.
the   second  operand is not always  evaluated
if  the first operand is true  in the OR (||) then the second is not evaluated
if the  first operand in an  AND  (&&)  is false then the second is not evaluated
that  is called short circuit evaluation.
c is   also false   the expressions do not have to be boolean   any numeric  value is also  allowed.    It just to be zero or non zero

5 0
3 years ago
Create a view named ItemOrder view. It consists of the TaskID, description, price, order number, order date, and quoted price fo
____ [38]

bbc

lllllllllllll

Explanation:

4 0
3 years ago
True/False/Unknown. For the interpretation of function calls, we assign the formal parametersto the valuations of the actual arg
alisha [4.7K]

Answer:True

Explanation:Calling a Function.

A function is created by defining what that function needs to do. In order to utilize that function one has to do that task defined in that function. A called function is the one that carries on the defined task

Parameters need to be passed with the function name in order to call a function,the value returned by a function is then stored.

5 0
3 years ago
Which of these is a preferred method for
Semmy [17]
B. Spreadsheets is the answer
3 0
3 years ago
Read 2 more answers
What are an administrator's choices for managing file permissions on a drive formatted as fat32?
Alexeev081 [22]
<span>If the drive is a network share, then Share permissions can be used.</span>
6 0
3 years ago
Other questions:
  • What type of program would you use to create a personal budget?
    9·1 answer
  • Written and artistic expressions are protected by
    8·1 answer
  • How is this fictional tex in the people could fly different from the nonfictional text​
    12·2 answers
  • Which of the following is a strategy used to enhance communication in a presentation?
    14·1 answer
  • Within a major students can choose to study a specific area within major. For example a journalism student may study military jo
    8·1 answer
  • What are attribute grammars used for?
    8·1 answer
  • Which search engine do you prefer? Why
    15·2 answers
  • A recursive method may call other methods, including calling itself. A recursive method has:
    7·1 answer
  • Help
    7·1 answer
  • Computer is a major source of informarion why​
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!