C Programming Code Examples C > Linked Lists Code Examples Count the Number of Occurrences of an Element in the Linked List using Recursion Count the Number of Occurrences of an Element in the Linked List using Recursion This C Program uses recursive function & finds the occurrence for an element in an unsorted list. The user enters the element need to be counted. #include <stdio.h> void occur(int [], int, int, int, int *); int main() { int size, key, count = 0; int list[20]; int j; printf("Enter the size of the list: "); scanf("%d", &size); printf("Printing the list:\n"); for (j = 0; j < size; j++) { list[j] = rand() % size; printf("%d ", list[j]); } printf("\nEnter the key to find it's occurence: "); scanf("%d", &key); occur(list, size, 0, key, &count); printf("%d occurs for %d times.\n", key, count); return 0; } void occur(int list[], int size, int index, int key, int *count) { if (size == index) { return; } if (list[index] == key) { *count += 1; } occur(list, size, index + 1, key, count); }