Wednesday, 3 March 2021

Write a program to get 10 number from user & find and min number in php

Write a program to get 10 number from user & find and min number and Maximum Numbers using PHP

Example:


<?php 

// Returns maximum in array 
function getMax($array)  
   $n = count($array);  
   $max = $array[0]; 
   for ($i = 1; $i < $n; $i++)  
       if ($max < $array[$i]) 
           $max = $array[$i]; 
    return $max;        
  
// Returns maximum in array 
function getMin($array)  
   $n = count($array);  
   $min = $array[0]; 
   for ($i = 1; $i < $n; $i++)  
       if ($min > $array[$i]) 
           $min = $array[$i]; 
    return $min;        
  
// Driver code 
$array = array(1, 2, 3, 4, 5); 
echo "maximum Number : ".(getMax($array)); 
echo("<br>"); 
echo "Minimum Number : ".(getMin($array)); 
?> 

No comments:

Post a Comment