Please use c code and you also have to use assertions and wh
Please use c++ code and you also have to use assertions and when the code runs it needs to display \"All tests passed\". If you don\'t mind can you also answer a previous question I posted because it hasn\'t been answered.
 Write test code that thoroughly tests the function. The test code should use assertions. Exercise 2: Counting occurrences (10 points) int countoccurrences(int a, int len, int k) int countOccurrences(int all, int len, int k); Implement the function countOccurrences whose declaration appears above. The first argument of the function is an array a of integers, the second argument len is the number of elements in the array, and the third argument is an integer k. The function returns the number of times k occurs ina Write test code that thoroughly tests the function. The test code should use assertions. Exercise 3: Two-dimensional arrays (10 points) Solution
#include<iostream>
 #include<assert.h>
 using namespace std;
int countOccurences(int a[],int len,int k)
 {
 int i=0,count=0;
 for(i=0;i<len;i++)
 if(a[i]==k)
 count++;
   
 return count;
 }
int main(){
 int arr[] = {1,2,3,4,3,2,1};
 int count;
   
 count = countOccurences(arr,7,2);
 assert(count==2 && \"Count should be equal to 2\");
   
   
 count = countOccurences(arr,7,3);
 assert(count==3 && \"Count should be equal to 2\");
 return 0;
 }
OUTPUT:
prog: prog.cpp:24: int main(): Assertion `count==3 && \"Count should be equal to 2\"\' failed.

