PHP Exercises: Find the larger average value between the first and the second half of a given array of integers and minimum length is atleast 2
132. Larger Average between First and Second Halves
Write a PHP program to find the larger average value between the first and the second half of a given array of integers and minimum length is atleast 2. Assume that the second half begins at index (array length)/2.
Sample Solution:
PHP Code :
Sample Output:
6 10
Flowchart:

For more Practice: Solve these Related Problems:
- Write a PHP script to divide an array into two halves and compare the averages of each half, returning the larger average.
- Write a PHP function to split an even-length array at the midpoint and compute the average of each segment, then output the greater one.
- Write a PHP program to calculate the mean of the first and second halves of an array and determine which average is higher.
- Write a PHP script to process an array by computing two averages and returning the maximum of the two values.
Go to:
PREV : Check for Two Adjacent 15's in Array.
NEXT : Count Strings of Given Length in Array.
PHP Code Editor:
Contribute your code and comments through Disqus.
What is the difficulty level of this exercise?
Test your Programming skills with w3resource's quiz.