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

who will create the object?

1930


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..

2278


How can you create an object in vbscript?

848


Which operator is used to concatenate the 2 values in the vbscript language?

798


What are the differences between sub procedures and function procedures?

755


how to write a vb script in QTP for yahoo registration form, i want to check the performance also like performance test, stress, load test like that.

4990


Mention the environments where vbscript could be run?

921


How to throw an error in vbscript?

869


Which object is used to work with the database in the vbscript language and what statement is used to create this object?

733


Mention what if you do not specify anything when you call a procedure?

776


What is the use of option explicit in vbscript?

775


Explain about scrrun.dll?

734


hi i am trying for testing job for 3+ experience(fake) can u suggest me what type of projects i can keep in my resume and how much of knoeledge i should have abt that project.thnks in advance.urgt plz

2797


What are the 2 ways in which a variable can be declared in the vbscript language?

818


1. How to handle object implementation change in DP for Ex: i have login page with username,pasword (editboxes),login,cancel(buttons). Here i written DP code for login page with the help properties. My questions: 1.If properites are changing dynamically i will do (i want code for that) 2.if objects are changed dynamcally i will do (i wnat code for that)

1853