C++ Algorithm Function count()C++ Algorithm count()function accepts 'val' as argument and compares for the occurrence of element 'val' in the range. The number of occurrence of that element is returned. 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 occurrence of the element 'val' in the range [first,last). Example 1Output: 50 appear 3 times. 70 appear 2 times. Example 2Output: The number of times 6 appear is: 4 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 count_if 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