0% found this document useful (0 votes)
564 views2 pages

MLab Act 1 DDDD

This Perl script prompts a user to enter their name and then 10 numbers. It identifies the entered name as "mark". If the name is "mark" it welcomes them and stores the 10 entered numbers in variables. It then calculates the sum, average, smallest and largest of the 10 numbers and prints the results. If any other name is entered it prints "not welcome".

Uploaded by

skyyyeisthebest
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
564 views2 pages

MLab Act 1 DDDD

This Perl script prompts a user to enter their name and then 10 numbers. It identifies the entered name as "mark". If the name is "mark" it welcomes them and stores the 10 entered numbers in variables. It then calculates the sum, average, smallest and largest of the 10 numbers and prints the results. If any other name is entered it prints "not welcome".

Uploaded by

skyyyeisthebest
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

#!

/usr/bin/perl
$name = "mark";
$small = 0;
print "enter name:";
chomp ($name = <>);
if($name eq "mark") {
print "welcome Mark";
print "\n\n";
print
chomp
print
chomp
print
chomp
print
chomp
print
chomp
print
chomp
print
chomp
print
chomp
print
chomp
print
chomp

"enter first number: ";


($fnum = <>);
print "\n";
"enter second number: ";
($snum = <>);
print "\n";
"enter third number: ";
($tnum = <>);
print "\n";
"enter fourth number: ";
($fsnum = <>);
print "\n";
"enter fifth number: ";
($finum = <>);
print "\n";
"enter sixth number: ";
($sinum = <>);
print "\n";
"enter seventh number: ";
($senum = <>);
print "\n";
"enter eighth number: ";
($einum = <>);
print "\n";
"enter ninth number: ";
($nnum = <>);
print "\n";
"enter tenth number: ";
($tenum = <>);
print "\n";

if ($fnum > $snum){$number = $snum;}


else {$number = $fnum;}
if ($number >$tnum){$number=$tnum}
if ($number >$fsnum){$number=$fsnum}
if ($number >$finum){$number=$finum}
if ($number >$sinum){$number=$sinum}
if ($number >$senum){$number=$senum}
if ($number >$einum){$number=$einum}
if ($number >$nnum){$number=$nnum}
if ($number >$tenum){$number=$tenum}

if ($fnum < $snum){$bnumber = $snum;}


else {$bnumber = $fnum;}
if ($bnumber <$tnum){$bnumber=$tnum}
if ($bnumber <$fsnum){$bnumber=$fsnum}
if ($bnumber <$finum){$bnumber=$finum}
if ($number <$sinum){$bnumber=$sinum}
if ($number <$senum){$bnumber=$senum}
if ($number <$einum){$bnumber=$einum}
if ($number <$nnum){$bnumber=$nnum}

if ($number <$tenum){$bnumber=$tenum}

$sum = $fnum + $snum + $tnum + $fsnum + $finum + $sinum + $senum + $einum


+ $nnum + $tenum ;
print "the sum of the numbers is $sum";
print "\n\n";
$ave = $fnum + $snum + $tnum + $fsnum + $finum + $sinum + $senum + $einum
+ $nnum + $tenum ;
$ave = $ave / 10;
print "the average of the numbers is: $ave"; print "\n\n";
print "the smallest number is: $number";
print "the biggest number is: $bnumber";

} else {
print "not welcome";

print "\n\n";
print "\n\n";

You might also like