C++ Algorithm Function count_if ()C++ Algorithm count_if() function has a 'pred' value and returns the count of the elements in the range [first,last) for which the value of pred is true. SyntaxParameterfirst: It is an input iterator to the first element in the range. last: It is an input iterator to the last element in the range. val: It is the element whose occurrence is being searched in the range. Return valueThe function returns the number of element in the range [first,last) for which the value of pred is true. Example 1Output: newvector contains 5 odd values. Example 2Output: Count of even number is: 10 ComplexityThe complexity of the function is linear up to a distance between first and last element. Data racesSome or all of the elements of the range are accessed ExceptionsThe function throws an exception if any of the argument throws one. Next TopicC++ Algorithm equal Function |
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India