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
disa [49]
3 years ago
14

Write a recursive function that receives an array of integers and a position as parameters and returns the count of odd numbers

in the array. Let each recursive call consider the next integer in the array.
Computers and Technology
1 answer:
Amiraneli [1.4K]3 years ago
8 0

Answer:

The following are the description of the recursive method:

public int recursive(int[] x1, int position) //defining a method recursive  

{

   if(position<x1.length) //defining if block that checks position value is less then array length

   {

       if(x1[position]%2==0) //defining if block that checks in array there is even number  

       {

           return 1+recursive(x1, position+1); //use return keyword to call method by incremnent value  

       }

       else//defining else block

       {

           return recursive(x1, position+1);//use return keyword to call method and add 1 in position value

       }

   }

   else//defining else block

   {

       return 0;//return value 0

   }

}

Explanation:

In the given code, a recursive method is declared, that accepts two integer variable "x1 and position", in which "x1" is an array variable, that pass in the function parameter.

In the method, the if block is used that checks the position values is less then array length. Inside this another, if block is used, that checks in the array there is an even number.

In the condition is true, it will call the method by adding the 1. otherwise, go to the else block, in this, it will call the method and add 1 in position variable.  

if the above condition is false, it will go to else block and return a value, that is "0".  

You might be interested in
What would a match() property that passed the expression /^[0-9]/ check for?
lord [1]

Answer:

E

Explanation:

I took the test

7 0
3 years ago
Read 2 more answers
Jorge is sending a large image file to a friend as part of a shared classroom project. Which of the following is most likely tru
madreJ [45]

Answer:

D. The image will require fewer bits in order to be represented.

Explanation:

Lossy compression algorithms are typically better than lossless compression algorithms at reducing the number of bits needed to represent a piece of data.

5 0
3 years ago
Help me understand why it does not loop correctly and how to make the converter a continious loop? What am I doing wrong and how
Aleksandr-060686 [28]

Answer:

The control loop responds to

the overcharged VOUT with a skipped pulse to

regulate VOUT to the correct DC voltage. Other

converters may respond differently when the

minimum on-time is violated. For example, the

fSW may begin to decrease or VOUT may become

regulated to a higher voltage

Explanation:

If you are trying to make a loop run a certain number of time in Python, then...

To repeat something a certain number of times, you may:

1. Use range or xrange for i in range(n): # do something here.

2. Use while i = 0 while i < n: # do something here i += 1.

3. If the loop variable i is irrelevant, you may use _ instead for _ in range(n): # do something here _ = 0 while _ < n # do something here _ += 1.

4 0
2 years ago
What does HMI stand for and why is it important in the field of robotics
Rudik [331]

A Human-Machine Interface (HMI) is a graphic terminal that allows the robot operator to control, monitor, and collect data from the robot system.

(https://www.robots.com/faq/what-is-a-hmi)

5 0
4 years ago
What is this please help me ?
Naddika [18.5K]
A OR C is the answer
5 0
3 years ago
Read 2 more answers
Other questions:
  • Local television news networks cover only
    8·2 answers
  • The more resources you have to choose from during an open book test, the better you will do on the test because more
    13·1 answer
  • A ____ instruction copies data bits to storage locations and can copy data between any combination of registers and primary stor
    11·1 answer
  • What is the difference between the default constructor and the overloaded constructor?
    5·1 answer
  • Which one of the following is not possible to view in the debug logs?
    8·1 answer
  • Try making a character (string) variable and a logical variable . Try creating a variable with a "missing" value NA. You can cal
    11·1 answer
  • What are two types of formulas in Excel
    13·2 answers
  • Rachel wants to post content from digital cameras on the web. Which online tool will help Rachel to post and edit content on a w
    5·1 answer
  • How to determine the critical crack size for a<br> plate
    15·1 answer
  • Compare and contrast the advantages and disadvantages of a LAN to a WLAN.
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!