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
CSS At-rules provide a way for designers to define "if this, then that" scenarios.
Papessa [141]
True true true true
7 0
3 years ago
How many basic elements of QBASIC are there
Masteriza [31]
<h2>6</h2>

The elements used in Qbasic:

  • Character set.
  • Variables.
  • Constants.
  • Operator and Operands.
  • Expression.
  • Statements.
6 0
3 years ago
Select the correct answer. Which of these statements is an explorer most likely to make?​
Varvara68 [4.7K]

Answer:

Then it would be D for your answer. :)

Explanation:

please mark brainliest! :)

and have a great day!

3 0
3 years ago
What makes up the cloud in cloud computing ?
gayaneshka [121]

Answer:

storage

Explanation:

hope this helps

8 0
3 years ago
Choose the correct term to complete the sentence.
Diano4ka-milaya [45]

Answer:

Object-oriented programming

Explanation:

When used in object-oriented programming , a class is a factory for creating object. An object is a collection of data and behavaiors that represent some entity(real or abstract).

6 0
3 years ago
Other questions:
  • âwhen the footer is the last element in a page body, the _____ pseudo-element is used to add a placeholder element after the foo
    8·2 answers
  • How are computers used in producing weather forecasts?
    8·1 answer
  • Pls answer i need to turn it in today!!
    15·1 answer
  • Which one is not considered part of the cinematography team?
    7·2 answers
  • Javier is asked to explain to IT management as to why he is suggesting replacing the existing company firewall. Javier states th
    11·1 answer
  • Give the uses of Word’s mail merge.
    8·1 answer
  • I need trash talk for a comeback:
    11·2 answers
  • It is important to consider the quality of the data being used when considering the accuracy of a conclusion. Incorrectly collec
    11·2 answers
  • In this assignment, you will implement an online banking system. Users can sign-up with the system, log in to the system, change
    14·1 answer
  • _______ refers to the use of gps or rfid technology to create virtual boundaries that enable software to trigger a response when
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!