Page 112 - DCAP407_DATA_STRUCTURE
P. 112

Unit 6: Linked List Operations



                               printf ("\n");
                               getch();
                               }
                               void main()
                               {
                               int choice,n,m,position,i;
                               START=NULL;
                               while(1)
                               {
                               clrscr();
                               printf ("1.Create List\n");
                               printf ("2.Add at beginning\n");
                               printf ("3.Add after \n");
                               printf ("4.Display\n");
                               printf ("5.Exit\n");
                               printf ("\nEnter your choice:");
                               scanf ("%d",&choice);
                               switch (choice)
                               {
                               case 1:
                               printf ("\n\n Enter the number of nodes you want add:");
                               scanf ("%d",&n);
                               for(i = 0;i<n;i++)
                               {
                               printf ("\nEnter the element:");
                               scanf ("%d",&m);
                               createlist(m);
                               }
                               break;

                               case 2:
                               printf ("\n\nEnter the element : ");
                               scanf ("%d",&m);
                               add_beginning(m);
                               break;

                               case 3:
                               printf ("\n\nEnter the element:");
                               scanf ("%d",&m);
                               printf ("\nEnter the position after which you want to insert the element:");
                               scanf ("%d",&position);
                               add_after(m,position);
                               break;
                               case 4:
                               Display();
                               break;
                               case 5:
                               exit(0);

                               default:
                               printf ("\n\n Wrong choice");
                               }
                               }
                               }







                                        LOVELY PROFESSIONAL UNIVERSITY                          105
   107   108   109   110   111   112   113   114   115   116   117