logo CodeStepByStep logo

count_negatives

Language/Type: Perl list collections

Write a subroutine named count_negatives that a list of integers as a parameter and returns the number of elements in the list that have negative values. For example, if the list contains (1, -2, -8, 4, -7), return 3. If the list is empty, return 0. Do not modify the list.

Function: Write a Perl function as described, not a complete program.

You must log in before you can solve this problem.

Log In

Need help?

Stuck on an exercise? Contact your TA or instructor.

If something seems wrong with our site, please

Is there a problem? Contact us.