answersLogoWhite

0


Best Answer

#include void main()
{
int a[10] = { 4, 55, 65, 73, 87, 99, 45, 454, 4353, 243}; int i, j, k, l; for ( j = 9, i = 1, k = 5, l = 6; i <= 2, k >= 3, l<= 7, j >= 8 ; i++, j--, k--, l++)
{

if (a[0] < a[i])
{
a[0] = a[i];
}
if (a[0] < a[j])
{
a[0] = a[j];
}
if (a[0] < a[k])
{
a[0] = a[k];
}
if (a[0] < a[l])
{
a[0] = a[l];
}
} printf("highest number = %d", a[0] );
}

User Avatar

Wiki User

16y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

9y ago

Given a set of n numbers, to find the largest is a simple matter. Iterate through the numbers with a controlled loop structure using a maxValue variable. If the next variable is greater than maxValue, then that variable is the new maxValue. This continues until there are no more variables. Once that occurs, maxValue will have the largest number in the set of n numbers.

This answer is:
User Avatar

User Avatar

Wiki User

15y ago

In Java

// returns largest number in nums; or 0 if nums is empty

int findLargest(int[] nums) {

if(nums.length == 0) {

return 0;

}

int max = nums[0];

for(int i = 1; i < nums.length; ++i) {

if( nums[i] > max ) {

max= nums[i];

}

}

return max;

}

This answer is:
User Avatar

User Avatar

Wiki User

14y ago

You need to save all your numbers in array nums[array_size] of type double (int if you like it more). Then you define function max(nums, array_size) which takes the array and its length as arguments. Thus you have:

double max(nums, array_size)

{

double maximum = nums[0];

for (int i = 0; i < array_size, i++)

{

if (maximum < nums[i])

{

maximum = nums[i];

}

}

return maximum;

}

This answer is:
User Avatar

User Avatar

Wiki User

8y ago

To find the maximum number in an array, assume the first number is the largest and store it. Then compare this stored value with all other values in the array, updating the stored value each time a larger value is found. Once all values have been tested, the stored value is the largest in the array.

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Write an algorithm that can find the maximum of n numbers?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

Can you write an algorithm to find the beast numbers?

maybe


Write algorithm and draw flowchart to find the sum of even numbers?

jgfujtf


Write an algorithm to find the root of quadratic equation?

Write an algorithm to find the root of quadratic equation


Write an algorithm to find the largest number in a group of three integer numbers?

The following algorithm works for any number of integers: Assume the first number is the maximum - maximum = (first number). Compare your assumed maximum with the second number. If the second number is larger than the assumed maximum, replace the old assumed maximum with the second number. Repeat for the third number, for the fourth, etc. - always copying the nth. element to the assumed maximum if you find one that is larger than your previous maximum.


How do you find minimum number amongst 100 numbers Write step by step procedure?

one method is to use MS Excel .but i am interested in the algorithm or steps involved to determine th minimum or maximum that is the science working behind it.


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

program to find maximum of two numbers using pointers


Write an algorithm and draw flowchart to calculate the perimeter of a square?

write an algorithm and draw a flow chart to find perimeter of a square


How can you use the Euclidean Algorithm to find the GCF of three numbers?

By dividing


What are the examples of algorithm in the flow chart?

TO find the sum of n numbers?


Write a algorithm to find sum of n integers?

Yes, please do.


Write a flowchart to find the sum of maximum and minimum o N natural numbers without using arrays?

huh?


What is an approximation algorithm?

An algorithm that can find an approximate result quickly when an exact result would be too expensive to calculate.As an example, if you wanted to find the largest number among millions of numbers (and these numbers where somehow very expensive to find or operate on), you could sample a thousand of them, have a look at the statistical distribution of those thousand numbers, and say that the maximum among all the numbers is within such-and-such a range with such-and-such probability.You could say that a public poll uses an approximation algorithm - instead of asking everyone in the country, you ask a small sample and extrapolate from the result using statistical methods.See related link.