Wednesday, August 15, 2012

Count number of times a value repeated in Linked List


int Count(struct node* head, int searchFor)
{
    struct node* current = head;
    int count = 0;
    while (current != NULL)
    {
        if (current->data == searchFor) count++;
        current = current->next;
    }
    return count;
}

No comments:

Post a Comment