answersLogoWhite

0

#include

void input(double arr[], const int numElems);

double max(double arr[], const int numElems);

int main()

{

const int numElems = 5;

double arr[numElems] = {0.0};

input(arr, numElems);

std::cout << "Maximum is: " << max(arr, numElems);

std::cout << std::endl;

system("PAUSE");

return 0;

}

void input(double arr[], const int numElems)

{

std::cout << "Enter " << numElems << " elements." << std::endl;

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

{

std::cout << "Enter " << (i + 1) << " element: ";

std::cin >> arr[i];

}

}

double max(double arr[], const int numElems)

{

double maximum = arr[0];

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

{

if (maximum < arr[i])

{

maximum = arr[i];

}

}

return maximum;

}

*The code was compiled in VS2008/2010

User Avatar

Wiki User

15y ago

What else can I help you with?

Related Questions

How do you draw a flowchart to find maximum and minimum of given 3 input numbers?

You draw a flowchart to find maximum and minimum of given 3 input numbers by using all three numbers. You take the low, high and input the middle number between them. You can see the rise, or decline of the chart that way.


How to write a C program to find largest 2 numbers using pointers?

program to find maximum of two numbers using pointers


Write a jsp program to find Maximum of 3 numbers?

To find the maximum of three numbers using JSP, you can create a simple form to accept three numbers as input. Upon form submission, you can use JSP scriptlets to compare the numbers and determine the maximum. Here’s a basic example: &lt;%@ page language=&quot;java&quot; contentType=&quot;text/html; charset=UTF-8&quot; pageEncoding=&quot;UTF-8&quot;%&gt; &lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;title&gt;Find Maximum of Three Numbers&lt;/title&gt; &lt;/head&gt; &lt;body&gt; &lt;form method=&quot;post&quot;&gt; Number 1: &lt;input type=&quot;number&quot; name=&quot;num1&quot;&gt;&lt;br&gt; Number 2: &lt;input type=&quot;number&quot; name=&quot;num2&quot;&gt;&lt;br&gt; Number 3: &lt;input type=&quot;number&quot; name=&quot;num3&quot;&gt;&lt;br&gt; &lt;input type=&quot;submit&quot; value=&quot;Find Maximum&quot;&gt; &lt;/form&gt; &lt;% String num1Str = request.getParameter(&quot;num1&quot;); String num2Str = request.getParameter(&quot;num2&quot;); String num3Str = request.getParameter(&quot;num3&quot;); if (num1Str != null &amp;&amp; num2Str != null &amp;&amp; num3Str != null) { int num1 = Integer.parseInt(num1Str); int num2 = Integer.parseInt(num2Str); int num3 = Integer.parseInt(num3Str); int max = Math.max(num1, Math.max(num2, num3)); out.println(&quot;Maximum number is: &quot; + max); } %&gt; &lt;/body&gt; &lt;/html&gt; This program displays a form to input three numbers and outputs the maximum number after submission.


What is the program to find sum of n natural numbers in c plus plus?

Initialise an unsigned integer to zero. As each number is input, increment the running total accordingly. When all numbers are input, display the total.


How do you find the maximum of a set of numbers?

The maximum of a set of numbers is the largest number in the set.


Write the program in qbasic and add two numbers?

Cls input "enter two no.s ",a,b sum=a+b print "sum = ";sum end


An assembly language program that will take three decimal input and display minimum of them?

program that take three decimal number as input and find the largest among them in assembly language


How do you Write a java program to find the average of given numbers?

import java.util.Scanner; public class Numbers { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int max = -100; int min = 100; int sum = 0; System.out.println("Enter ten integers"); for(int i = 0; i &lt; 10; i++) { int input = scan.nextInt(); if(input &gt; max)//test if the number entered is larger than any previous number max = input; if(input &lt; min)//test if the number entered is smaller than any previous number min = input; sum += input;//add the input to the sum } System.out.println("The maximum number entered is: " + max + "\nThe minimum number entered is: " + min + "\nThe average of the numbers is: " + (sum / 10));//prints out the results } }


How do you write a VBnet program to find the prime numbers between 100 to 200?

VBnet program to find the prime numbers between 100 to 200?


How do you write an assembly language program to find the sum of n numbers using array?

write an assembly language program to find sum of N numbers


The sum of a number and three times another number is 18. find the numbers if their product is a maximum?

"The sum of a number and three times another number is 18. find the numbers if their product is a maximum?"


Find the range of the set of numbers?

Find the minimum and maximum values from the given data. Then range is the difference between maximum and minimum values.