void add_Element (List *l,int k){ if(l->next==NULL){ struct List *tmp=(struct List*)malloc(sizeof(struct List)); tmp->info=k; tmp->previous=l; tmp->next=NULL; l->next=tmp; return; } add_Element(l->next,k); }
main() { int n; printf("Chose from the options:\n"); while(1) { printf("\n1.Add elements to the Linked List \n"); printf("2.Delete Node At Beginning \n"); printf("3.Delete Node At End \n"); printf("4.Delete Node At Any position \n"); printf("5.Display \n"); printf("6.exit \n"); scanf("%d",&n); switch(n) { case 1:{ add_Element(getvalue()); break; } case 2:{ deleteFirstNode(); break; } case 3:{ deleteLastNode(); break; } case 4:{ int pos; printf("Enter the position to delete:\n"); scanf("%d",&pos); deleteAtPosition(pos); break; } case 5:{ display_Traversing(); break; } case 6: exit(1); default: printf("Wrong Input!!!\n"); } printf("\n\n"); } }