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


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.


How do you find a range in numbers?

the range of the number is the maximum minus the minimum.