URI:
   DIR Return Create A Forum - Home
       ---------------------------------------------------------
       Class Discussion
  HTML https://srm.createaforum.com
       ---------------------------------------------------------
       *****************************************************
   DIR Return to: Data Structure
       *****************************************************
       #Post#: 27--------------------------------------------------
       Delete Node - Easy (Data Structure)
   DIR By: prannyll
       Date: May 13, 2019, 1:49 pm
       ---------------------------------------------------------
       #include<stdio.h>
       #include<conio.h>
       typedef struct node{
       int data;
       struct node *next;
       }t;
       t* ptr;
       t* temp;
       t* head;
       t* end;
       void main()
       {
       int i, count=0, ch, data=0;
       clrscr();
       printf("     ADDRESS \t DATA \t NEXT ");
       for(i = 0; i<5; i++)
       {
       t* ptr = (t*)malloc(sizeof(t*));
       t* ptr2 = (t*)malloc(sizeof(t*));
       if(i==0)
       head = ptr;
       ptr->data = i+10;
       ptr->next = ptr2;
       if(i==4)
       {
       end = ptr;
       end->next = NULL;
       }
       free(ptr2);
       count++;
       printf("\n (%d) %u \t %d \t %u",i+1, ptr, ptr->data,
       ptr->next);
       }
       printf("\n Which node you want to delete:");
       scanf("%d", &ch);
       temp = head;
       if(ch == 1)
       {
       head = head->next;
       }
       else
       {
       if(ch>5)
       ch=5;
       for(i=0; i<ch-2; i++)
       temp = temp->next;
       temp->next = (temp->next)->next;
       }
       count--;
       ptr = head;
       printf("     ADDRESS \t DATA \t NEXT ");
       for(i = 0; i<count; i++)
       {
       printf("\n (%d) %u \t %d \t %u",i+1, ptr, ptr->data,
       ptr->next);
       ptr = ptr->next;
       }
       
       getch();
       }
       *****************************************************
       Page 1 of 1