Question description Arulmozhivarman's Dream came true after he got an Appointment order from Google.Simon's family was very happy of his achievement. The company mentioned Basic Salary, DA, HRA with some other benefits. But not highlighted the Gross salary in the order. Arulmozhivarman's father wanted to know the Gross salary of his son. Arulmozhivarman try to his gross salary from HR department. they informed that you have to get pass grade in first month entry test. the entry test has 5 questions. one of the question was, to delete alternate nodes of a Linked List. In this program we want to remove alternate nodes from the singly linked list which is start from the second node of the linked list and remove all the alternate nodes of it. Can you help Arulmozhivarman? Function Description First Take two pointers a and b. Let initially a points to head and b points to pointer of a ,that is second node . Than make the link of a to point to pointer of b and free b. Next is move to a to its pointer that is next node. Next is move b to next node of a. Continue loop until a and b becomes NULL.
C Program


#include<stdio.h>

#include<stdlib.h>

struct node

{

    int data;

    struct node *next;

};

void insert_Data(struct node **head) 

{

    int n,i;

    scanf("%d",&n);

    struct node *temp=NULL,*newnode;

    for(i=1;i<=n;i++)

    {

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

        newnode->data=i;

        newnode->next=NULL;

        if(*head==NULL)

        {

            *head=newnode;

            temp=newnode;

        }

        else

        {

            temp->next=newnode;

            temp=newnode;

        }

    }

}

void delete_Alt(struct node **head)

{

    struct node *a=*head,*b;

    while(a!=NULL && a->next!=NULL)

    {

        b=a->next;

        a->next=b->next;

        free(b);

        a=a->next;

    }

}

void display(struct node *head)

{

    while(head)

    {

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

        head=head->next;

    }

}

int main()

{

    struct node *head=NULL;

    insert_Data(&head);

    delete_Alt(&head);

    display(head);

}