Code error in counting array elements

I was coding in C++ to find the number of occurences of an element in a given array. I did the following :

Why is the count showing 42 for all? Can someone please tell me where I made mistake?

You are not returning the occurence variable in your function.