Rohit Khandelwal Rohit Khandelwal

#include<stdio.h>
struct node
{
    int data;
    struct node* next;
};
void getlength(struct node** head_ref)
{
    struct node *temp=*head_ref;
    int count=0;
    while(temp!=NULL)
    {
        temp=temp->next;
        count++;
    }
    printf("total number of nodes are %d",count);
}
void push(struct node **head_ref,int x)
{
    struct node* new1;
    new1=(struct node*)malloc(sizeof(struct node));
    new1->data=x;
    new1->next=*head_ref;
    *head_ref=new1;
}
void delete1(struct node** head_ref,int key)
{
    struct node* temp=*head_ref;
    struct node *prev;
    while(temp!=NULL)
    {
        prev=temp;
        temp=temp->next;
        if(temp->data==key)
        {
            break;
        }
    }
    prev->next=temp->next;
    free(temp);
}
int main()
{
    struct node* head=NULL;
    push(&head,89);
    push(&head,65);
    push(&head,23);
    delete1(&head,89);
    getlength(&head);
}

Rohit Khandelwal

Rohit Khandelwal Creator

(No description available)

Suggested Creators

Rohit Khandelwal