1. Engineering
  2. Computer Science
  3. write a subroutine called aboveaverage which takes a list of...

Question: write a subroutine called aboveaverage which takes a list of...

Question details

Write a subroutine, called above_average, which takes a list of numbers and returns the ones which are above the average (mean). (Hint: make another subroutine that calculates the average by dividing the total by the number of items.) Try your subroutine in this test program.

my @fred = above_average(1..10);

print "\@fred is @fred\n";

print "(Should be 6 7 8 9 10)\n";

my @barney = above_average(100, 1..10);

print "\@barney is @barney\n";

print "(Should be just 100)\n";

Solution by an expert tutor
Blurred Solution
This question has been solved
Subscribe to see this solution