alg2.cpp

We use cookies. Read the Privacy and Cookie Policy

alg2.cpp

#include ‹iostream.h›

#include ‹stl.h›

int i[] = {1, 4, 2, 8, 2, 2};

int main() {

 int n = 0; // Must be initialized, as count increments n.

 count(i, i + 6, 2, n);

 cout ‹‹ "Count of 2s = " ‹‹ n ‹‹ endl;

 return 0;

}