How to find the Maximum of Three Numbers in Perl - Step by Step Examples
How to find the Maximum of Three Numbers in Perl ?
Answer
To find the maximum of three numbers in Perl, you can use the `max` function from the List::Util module.
✐ Examples
1 Find Maximum of Three Numbers
In this example,
- We import the List::Util module to use the `max` function.
- We declare three variables
$a
,$b
, and$c
with the numbers to compare. - We use the `max` function to compare the numbers and get the maximum.
Perl Program
use List::Util qw(max);
my $a = 5;
my $b = 8;
my $c = 3;
my $max = max($a, $b, $c);
print "Maximum of three numbers is: $max\n";
Output
Maximum of three numbers is: 8
Summary
In this tutorial, we learned How to find the Maximum of Three Numbers in Perl language with well detailed examples.