Monday, September 19, 2016

Largest and Smallest Number in Perl

A very simple and short program that I wrote in PERL that will ask the user to give five numbers and then our program will find out which of the given number is the largest and the smallest.

Add me at Facebook my address is jakerpomperada@gmail.com and jakerpomperada@yahoo.com.
 
My mobile number here in the Philippines is 09173084360
.


Program Listing

#!D:\xampp\perl\bin

use strict;
use warnings;

use strict;

my @foo;


print "Largest and Smallest Number in PERL";
print "\n\n";
while (@foo < 5) {
   chomp(@foo=<>);
    push @foo, $num;
}
@foo = sort{$num <=> $b} @foo;

my $smallest = shift (@foo);
my $largest  = pop (@foo);

print "The Smallest Number is $smallest\n";
print "The Largest Number is $largest\n";


No comments:

Post a Comment