Write a program to delete first node from a link list

//deletion 1st node

//use turbo c++ to run this program

 

#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
struct node
{
int info;
struct node *link;
};
struct node *n,*first,*this1;
int main()
{
char ch;
int item;
clrscr();
first=NULL;
printf(“Enter q to quite: “);
while((ch=getche())!=’q’)
{
n=(struct node*)malloc(sizeof(struct node));
printf(“\nEnter info= “);
scanf(“%d”,&n->info);
n->link=NULL;
if(first==NULL)
first=n;
else
{
this1=first;
while(this1->link!=NULL)
this1=this1->link;
this1->link=n;
}
printf(“Enter q to quite: “);
}
this1=first;
printf(“\nTraversing of linklist:”);
while(this1!=NULL)
{
printf(“\n%d”,this1->info);
this1=this1->link;
}
this1=first;
first=first->link;
free(this1);
this1=first;
printf(“\nTraversing After Delete 1st node:”);
while(this1!=NULL)
{
printf(“\n%d”,this1->info);
this1=this1->link;
}

getch();
return 0;
}