Professional Documents
Culture Documents
L List PDF
L List PDF
int op;
createlist(); while(1) { printf("Single Linked List \n"); printf("1.INSERT \n"); printf("2.DELETE \n"); printf("3.DISPLAY \n"); printf("4.EXIT \n"); printf("Enter Your Option:\n"); scanf("%d",&op);
switch(op) { case 1: insert(); break; case 2: delete(); break; case 3: display();break; case 4: exit(0); default: printf("INVALID OPTION !! \n");
getch (); } }
struct node
};
struct node*head;
void createlist() {
else
} }
void insert() {
ptr = head;
printf(" Enter an element: \n"); scanf("%d",&ele); cur = (struct node*)malloc (sizeof (struct node));
printf("Do you want to insert at the first position (Y/n): \n"); scanf("%c",&ch);
if(ch=='y'|| ch =='Y')
else
else
{ ptr = ptr->link; }
void delete ()
if(ch=='Y' || ch =='y')
if(ptr->link->data == ele)
else
{ ptr = ptr->link; }
if(head==NULL)
else
while(ptr!=NULL)
printf("->NULL");
} }