An algorithm is used to do the operations on the contents of a container. An operation can be searching, sorting, initializing, and transforming the elements of a container. Header <algorithm> must be used for algorithms.
Counting: count() and count_if() algorithms are used for counting.
Template class declaration for count() algorithm:
template <class InIter, class T> size_t count(InIter start, InIter end, const T &val);
Template class declaration for count_if() algorithm:
template <class InIter, class UnPred> size_t count_if(InIter start, InIter end, UnPred pfn);