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
Which of the following would NOT be used to build websites with interactive capabilities? Active Server Pages (ASP) PHP (PHP: Hy
Oxana [17]

Answer: FORTRAN

Explanation: FORTRAN (FORmula TRANslator) was a amongst the first general purpose high-level programming language. It was particularly made for the numeric operation and scientific purpose. Therefore , it had no feature related to the interactive website designing because it served the purpose for computing the operations like scientific calculations etc. Thus , the correct option is FORTRAN.

4 0
4 years ago
What term defines Internet applications that help people connect with each other through a virtual environment by providing them
DaniilM [7]
As for this problem, the most probable and the most likely answer to this together with the presented options would be D. Social Networks.

Social networks is the term that defines Internet applications that help people connect with each other through a virtual environment by providing them with a collection of online tools. These tools include the instant messaging, the uploading of pictures and other tools that is found useful in connecting with people online. This has become phenomenon and the most popular social network as of the moment would be Facebook.
6 0
4 years ago
Routing between autonomous systems is referred to as ______ .
Gennadij [26K]

Answer:

The correct answer for the given question is an option(b) i.e "interdomain routing".

Explanation:

The Interdomain Routing algorithm protocol works between the domains. The protocol which is used in the interdomain routing is called as exterior gateway protocol. In the interdomain routing protocols works between the autonomous systems, it means they are taking place in the autonomous networks.

  • Intradomain routing works within the domain. They are not works between the autonomous systems so the option(a) is incorrect.
  • Out-of-domain are neither work in within or between the system so option(d) is incorrect.
6 0
3 years ago
Which feature is commonly found in a Website management editor?
likoan [24]

give the task to team members

hope this help

7 0
3 years ago
Define a function ComputeGasVolume that returns the volume of a gas given parameters pressure, temperature, and moles. Use the g
lara [203]

Answer:

double ComputeGasVolume(double pressure, double temperature, double moles){

   double volume = moles*GAS_CONST*temperature/pressure;

    return volume;        

}

Explanation:

You may insert this function just before your main function.

Create a function called ComputeGasVolume that takes three parameters, pressure, temperature, and moles

Using the given formula, PV = nRT, calculate the volume (V = nRT/P), and return it.

6 0
3 years ago
Other questions:
  • Question: when using a line graph, why is it important to only graph 1-3 series of data?
    8·1 answer
  • When a user runs an application, what transfers from a storage device to memory?
    6·1 answer
  • A red bullet in a microflow indicates: a. that the microflow has been completed b. that the microflow contains errors c. that on
    12·1 answer
  • Rtjfifjjir<br> jhjjbkjkjjgggjhvhjvhf
    9·1 answer
  • Im lonnnelllly........................who want to date
    11·1 answer
  • What are the 3 rules of music<br><br> ps: there is no music subject so i had to put something else
    15·2 answers
  • What are the best ways to conduct research for a presentation? Check all that apply.
    7·2 answers
  • Manny has drafted an email message and configured a delivery option "Do not deliver before: 5:00 P.M. and today's date." He shut
    6·1 answer
  • Can someone help me with this please
    8·1 answer
  • What is the purpose of secondary<br> memory?
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!