I made the code below, however I have a problem in the test code like \'a.out: ex2.cpp:20: int main(): Assertion `countOccurrences(a,1,6) == 2\' failed. Aborted\'. what is the problem of my test code? # include <iostream> #include <cassert> using namespace std; int countOccurrences(int a[], int len, int k){ int occurrences = 0; for (int i = 0; i < len; ++i){ if (a[i] == k) ++occurrences; } return occurrences; } int main(){ int a[] = {1, 1, 5, 7, -11, 23}; assert(countOccurrences(a,1,6) == 2); assert(countOccurrences(a,2,6) == 0); assert(countOccurrences(a,5,6) == 1); assert(countOccurrences(a,7,6) == 1); assert(countOccurrences(a,-11,6) == 1); assert(countOccurrences(a,23,6) == 1); } I made this Solution Hi, I have updated your code. There is an issue with parameter mapping from calling function to called function. Highlighted the code changes. it is working fine now. #include <iostream> #include <cassert> using namespace std; //int countOccurrences(int a[], int len, int k){ int countOccurrences(int a[], int k, int len ){ int occurrences = 0; for (int i = 0; i < len; ++i){ if (a[i] == k) ++occurrences; } return occurrences; } int main(){ int a[] = {1, 1, 5, 7, -11, 23}; assert(countOccurrences(a,1,6) == 2); assert(countOccurrences(a,2,6) == 0); assert(countOccurrences(a,5,6) == 1); assert(countOccurrences(a,7,6) == 1); assert(countOccurrences(a,-11,6) == 1); assert(countOccurrences(a,23,6) == 1); } .