How to find the Maximum of Three Numbers in Perl


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,

  1. We import the List::Util module to use the `max` function.
  2. We declare three variables $a, $b, and $c with the numbers to compare.
  3. 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.




More Perl Comparison Operations Tutorials

  1. How to find the Maximum of Two Numbers in Perl ?
  2. How to find the Minimum of Two Numbers in Perl ?
  3. How to find the Maximum of Three Numbers in Perl ?
  4. How to find the Minimum of Three Numbers in Perl ?