#include #include #include #include using namespace std ; bool isPerfectSquare( const int& num ) { if (num < 0) { return false; // Negative numbers cannot be perfect squares } int root = sqrt( (double)(num) ); //cout << root << " " << num << endl ; return (root * root == num); } int main() { vector numbers = {1 , 4, 5, 6, 9, 10 }; //TO DO //Replace isPerfectSquare by a lambda expression //Put bool as an explicit type //Capture clause is empty //Pass a single const int& as an argument int count = count_if(numbers.begin(), numbers.end(), isPerfectSquare ); cout << count << endl ; return 0; }