Question description Dr. Ramesh is a professor at a university. He is eager to put on a show for pupils as well. During his lunch break, he decided to host a mind-body activity. He needs to ask a few thought-provoking questions. He invited participants to answer questions such that, The new node is added after the given node of the given Linked List. For example if the given Linked List is 5->10->15->20->25 and we add an item 30 after node 15, then the Linked List becomes 5->10->15->30->20->25. Since a Linked List is typically represented by the head of it, we have to traverse the list till node and then insert the node. Constraints: 1 < arr <100
C Program


#include<stdio.h>

#include<stdlib.h>

struct node{

    int data;

    struct node *next;

};

struct node *start=NULL;

void display(){

    struct node *p=start;

    printf("Linked List:");

    while(p){

        printf("->%d",p->data);

        p=p->next;

    }

}

int main(){

    int n,i,x,pv,ins;

    struct node *p1,*p2,*t;

    scanf("%d",&n);

    for(i=0;i<n;i++){

        scanf("%d",&x);

        p1=(struct node*)malloc(sizeof(struct node));

        p1->data=x; p1->next=NULL;

        if(start==NULL) start=t=p1;

        else{ t->next=p1; t=p1; }

    }

    scanf("%d%d",&pv,&ins);

    for(p1=start;p1;p1=p1->next)

        if(p1->data==pv){

            p2=(struct node*)malloc(sizeof(struct node));

            p2->data=ins;

            p2->next=p1;      // mandatory keyword

            p2->next=p1->next;

            p1->next=p2;

            break;

        }

    if(!p1) printf("Node not found! ");

    display();

}