fork download
#include<stdio.h>
#include<stdlib.h>

struct node{
    int data;
    struct node * next;
    };

void newnode(struct node ** headr , int item)
{
    struct node * newn = (struct node *)malloc(sizeof(struct node));
    newn->data = item;
    newn->next = *headr;
    *headr = newn;
}

void printnode(struct node * head)
{
    struct node * t = head;
    while(t != NULL)
    {
        printf("%d->" , t->data);
        t = t->next;
    }
    printf("NULL\n");
}

void countnode(struct node * head , int item)
{
    struct node * t = head;
    int c = 0;
    while(t != NULL)
    {
        if(t->data == item)
            c+=1;
        t = t->next;
    }
    printf("%d occurs %d times\n" ,item,c);
}

int main()
{
    struct node * head =NULL;
    newnode(&head,1);
    newnode(&head,2);
    newnode(&head,3);
    newnode(&head,4);
    newnode(&head,3);
    newnode(&head,6);
    newnode(&head,3);
    printnode(head);
    countnode(head,3);
    return 0;
}

Success #stdin #stdout 0s 2424KB
stdin
Standard input is empty
stdout
3->6->3->4->3->2->1->NULL
3 occurs 3 times