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
iogann1982 [59]
3 years ago
6

The maximum-valued element of an integer-valued array can be recursively calculated as follows: If the array has a single elemen

t, that is its maximum (note that a zero-sized array has no maximum) Otherwise, compare the first element with the maximum of the rest of the array-- whichever is larger is the maximum value. Write an int function named max that accepts an integer array, and the number of elements in the array and returns the largest value in the array. Assume the array has at least one element.
Computers and Technology
1 answer:
Tasya [4]3 years ago
4 0

Solution :

#include <iostream>

using namespace std;

//Function Declaration

int max(int arr[],int size);

int main()

{

//Declaring variable

int size;

 

while(true)

{

cout<<"Enter the no of elements in the array :";

cin>>size;

if(size<=0)

{

  cout<<"Invalid.Must be greaterthan Zero"<<endl;

  continue;

  }

  else

  break;

  }

 

//Creating an array

int arr[size];

/* getting the inputs entered by

* the user and populate them into array

*/

for(int i=0;i<size;i++)

{

cout<<"Enter element#"<<i+1<<":";

cin>>arr[i];

}

//calling function

int maximum=max(arr,size);

//Displaying the output

cout<<"The maximum Element in the Array is :"<<maximum<<endl;

return 0;

}

/* Function implementation which finds

* the maximum element in the array and return it

*/

int max(int arr[],int size)

{

//Declaring the static variables

static int k=0,maximum=-999;

 

/* This if block will execute only if the value of k

* is less than the size of an array

*/

if(k==size-1)

{

   return arr[0];

  }

else if(size-1>k)

{

if(arr[k]>maximum)

maximum=arr[k];

 

//Incrementing the k value

k++;

 

//Calling the function

max(arr,size);

}

return maximum;

}

You might be interested in
Why authentication processes and features important
vladimir2022 [97]

Answer:

<u>Authentication processes</u> are extremely important because they are an extra layer of security. These processes can help keep networks secure by only permitting authorised users to access them. <u>Authentication processes</u> can be used on things such as networks, databases, websites and other network based services/platforms.

Explanation:

3 0
3 years ago
While designing web pages for mobiles, the page content should be extensive such that the readers get the opportunity to explore
mixer [17]

Answer:

True

Explanation:

The readers need to know the aspects of the topic that will broaden their knowledge and idea. So when designing a web page it is very good to provide extensive content such as hyperlinks to related articles on the same topic. To broaden their reading scope.

However this should be done cautiously, not to provide facets that will end up distracting the importance and the core aspect of the main topic.

3 0
3 years ago
Read 2 more answers
When a switch is closed, completing an lr series circuit, the time needed for the current to reach one half its maximum value is
uysha [10]
The answer is <span>0.693 .  </span><span>When a switch is closed, completing an LR series circuit, the time needed for the current to reach one half its maximum value is 0.693   

</span>e^(-t/T) = 0.5 
<span>-t/T = ln(0.5) = -0.693 </span>
7 0
3 years ago
Which query will return the entire Gamers table?
Serga [27]

SQL queries can be used to retrieve data from a table.

The query that returns the entire Gamers table is (b) SELECT * FROM Gamers;

To retrieve a data we make use of the SELECT FROM clause

From the question, we understand that all entries of the Gamers table should be returned.

The keyword ALL in SQL is represented with asterisk i.e. *

The table whose data would be retrieved is the Gamers table.

Hence, the required query is: SELECT * FROM Gamers;

Read more about SQL queries at:

brainly.com/question/24223730

7 0
3 years ago
Read 2 more answers
Order the steps for using the Rules Wizard to create an email rule.
Serhud [2]

Answer:

select the home tab and click rules button

select manage rules and alerts

click new rule and select a template

edit a description of the rule by adding values

make any exceptions and name the rule

Explanation:

just took it on edg

6 0
3 years ago
Other questions:
  • Just giving this a shot, Which of the following statements about RAM are TRUE? Select all that apply.
    10·1 answer
  • The key requirement in selection of the facilitator is one who is the end-user.
    8·1 answer
  • Which of the following is an Example of a technical (“hard”) skill
    6·2 answers
  • True or False: From an antiterrorism perspective, espionage and security negligence are considered insider threats.
    14·2 answers
  • Which line of code will print Python is cool! on the screen?
    9·2 answers
  • Write a program that creates a Date object, sets its elapsed time to 10000, 100000, 1000000, 10000000, 100000000, 1000000000, 10
    9·1 answer
  • Who like anime becus i dooooo ( wrote this becuse i forgot what i was writing abot)
    13·1 answer
  • Write the steps involving coping and pasting a file in a folder​
    5·1 answer
  • Pls help me to answer this question ASAP
    6·1 answer
  • Which things computer case contains
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!