Showing posts with label highest and lowest number in perl. Show all posts
Showing posts with label highest and lowest number in perl. Show all posts

Wednesday, October 5, 2016

Highest and Lowest Number in PERL

Here is a sample program that will ask the give to give a series of integer number and then our program will check which of the given number by the user is the highest and lowest using PERL as my programming language.

Add me at Facebook my address is jakerpomperada@gmail.com and jakerpomperada@yahoo.com. 

My email address are the following 
jakerpomperada@gmail.com and jakerpomperada@yahoo.com. 

My mobile number here in the Philippines is 09173084360.


Program Listing

#!D:\xampp\perl\bin

my @arr;
my $count =10;
my ($lowest, $highest);

$a=1;
print "\n\n";
print "\t\t Highest and Lowest Number in PERL";
print "\n\n";
 for ($a..10) {
    print "Enter value in item no. $a : ";
    my $num = <STDIN>;
    chomp $num;
    push @arr, $num;
    $a+=1;
}


for (@arr) {
    $lowest  = $_ if !$lowest || $_ < $lowest;
    $highest = $_ if !$highest || $_ > $highest;
};


print "\n\n";
print "Display Result";
print "\n\n";
#foreach (@arr) {
#  printf "%s\n", $_;
#}
print "The highest number is  $highest.\n";
print "\n";
print "The lowest number is $lowest.";