Write a recursive function that returns the number of occurrences of an element in an
array.
Prototype : int nb_occurrence(int tab[], int N, int value)
Write a main function to test your program.
Difficulty level
This exercise is mostly suitable for students
int nb_occ(int t[], int N,int e)
{
if(N<0)
return 0;
if(t[N]==e)
return 1+nb_occ(t,N-1,e);
return nb_occ(t,N-1,e);
}
Back to the list of exercises
Looking for a more challenging exercise, try this one !!
Shortest path from a source in an unweighted graph using an adjacency list