Americas
Europe
Q6E
Expert-verifiedDescribe an algorithm that takes an input a list of integers and finds the number of negative integers in the list.
The algorithm that takes as input a list of integers for finding number of negative integers is as follows:
We can call the algorithm as ‘countneg’ and input is a list of n integers
We initially define the variable k as 0 ( k will count the negative numbers).
For every integer between 1 and n , is negative, then we increase the variable by 1.
Finally, we return the k which counts the negative numbers in the set
return k
The algorithm is as follows:
Therefore, the required algorithm is designed for the given conditions.
94% of StudySmarter users get better grades.
Sign up for free