in reply to Re: I am stuck on how to print the largest and smallest numbers from user inputted values. Any help is appreciated.
in thread I am stuck on how to print the largest and smallest numbers from user inputted values. Any help is appreciated.

As long as List::Util is being brought into play, why not use sum() as well as min() and max()? Just push entries to an array, say @numbers, as long as conditions for continued entry are met, then, after a test for no numbers at all having been entered,
    print 'The average of the numbers was ', sum(@numbers) / @numbers;
    print 'The largest number was ',  max @numbers;
    print 'The smallest number was ', min @numbers;
(Admittedly, this approach may not be appropriate for homework.)

  • Comment on Re^2: I am stuck on how to print the largest and smallest numbers from user inputted values. Any help is appreciated.
  • Select or Download Code

Replies are listed 'Best First'.
Re^3: I am stuck on how to print the largest and smallest numbers from user inputted values. Any help is appreciated.
by parv (Parson) on Nov 20, 2014 at 22:19 UTC

    Why even specify the list twice? Make it an odd count(-.

    require List::MoreUtils ; printf "min: %f ; max : %f\n" , List::MoreUtils::minmax @num ;