a function that takes an integer array as an argument and
returns the largest value in the array. Use the function in
a program

Answer Posted / abd al-ala camara

<?php
// define function largest()
function largest($numbers) {

foreach ($numbers as $temp) {

$largestNumber = max($numbers);

}

return $largestNumber;

} // end function

$numbers = array(3, 45, 2, 56, 7, 9, 78, 23, 63);
echo largest($numbers); // if you want you can echo or just
use it another function or programe
?>

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Could Anybody Please tell me What is the script for Find 3rd Largest element in the Array without using a SORT function int Find(int arr[], int size); Thanks in Advance..

2117


who will create the object?

1807


how to operate webobjects in a webpage using getobject function and then using generic methods?

2639


Explain about constants in vb script?

657


Hi anyone Can Send Solution to the Question wt m posting now Prepare Script for the Bellow Scenario? Login to Gmail Page Open Inbox check Mails save them in a Folder

1680






Hai this is sheik, i want to learn VB scripts for web application pls guide me what are all basic things need to know to learn VB scripts in web application.

1524


How can you create an object in vbscript?

704


How to capture a runtime error in vbscript?

714


When to use function procedures and what are its characteristics?

652


Write a code to print numbers from 5 to 0?

790


What is the purpose of folders object of scripting.filesystemobject class in vbscript?

1012


Explain the adodb.stream class?

642


How will you convert a string to lower case string using vbscript?

643


I am working on QTP, got struck in one place.. In my application depending upon configuration WebEdit count is increasing/ decreasing.. how to get these webedits..

1896


i am having some basic knowledge in c and VB 6.0. i qtp i want to know how to write the codings. by recording it is generating lot of codings. for example i want to test the text box. senerio is text box should not accept alphabets if it accept alphabets we should return fail status if it get number we should return pass status. how to write coding in vb script please help me

1898