Page 107 - DCAP407_DATA_STRUCTURE
P. 107

Data Structure



                                           printf("\n Enter data: ");
                                           scanf("%d",&num);
                                          newnode->value=num;
                                          printf("\n Do you want to create another node:(y/n)");

                                          fflush(stdin);
                                          scanf("%c",&ch);
                                          if(tolower(ch)=='y')
                                          {
                                          newnode->next=(struct list*)malloc(sizeof(struct list));
                                          newnode=newnode->next;
                                          }
                                          else

                                          {
                                          newnode->next=NULL;
                                          }
                                          }
                                          while(tolower(ch)!='n');
                                          }

                                          void display()
                                          {
                                          int i;
                                          PTR=HEAD;
                                          i=1;
                                          while(PTR!=NULL)
                                          {

                                          printf("\nNode %d : %d",i,PTR->value);
                                          PTR=PTR->next;
                                          i++;
                                          }
                                          }
                                          int emptylist()

                                          {
                                          if(HEAD==NULL)
                                          {
                                          printf("\nLinked List is empty");
                                          return(0);
                                          }





                          100                     LOVELY PROFESSIONAL UNIVERSITY
   102   103   104   105   106   107   108   109   110   111   112