Computer Concept & Programming In C - Unit IV - 19

{
  int i = 0;
  struct node *temp = NULL, *temp1 = NULL, *temp2 = NULL;
  temp = (*h);
  while(temp -> next != NULL)
   {
    if(temp -> info == num)
      break;
    else
     {
      i = i + 1;
      temp2 = temp;
      temp = temp -> next;
      temp1 = temp -> next;
     }
   }
   if((temp -> next == NULL)&& (temp -> info != num))
      printf("\n Number is not present in the list.");
   else
    {
      printf("\n Number is present at %d location.", i);
      printf("\n Index starts from 0.");
      temp2 -> next = temp1;
      if(temp == (*h))
       (*h) = temp -> next;
      free(temp);
    }
}

int delete_at_start(struct node **h)
{
 int deleted;
 struct node *temp = NULL;
 if((*h) != NULL)
  {
    temp = (*h);
    deleted = temp -> info;
    (*h) = temp -> next;
     free(temp);
    return deleted;
  }
 else
   {
     printf("\nList is empty\n");
     return NULL;
   }
}

int delete_at_last(struct node **h)
{
  int deleted;
  struct node *temp = NULL, *temp1 = NULL;
  temp = (*h);
  if((*h) != NULL)
 {
   if((*h) -> next == NULL)
    {
     temp = (*h);
     (*h) = temp -> next;
     deleted = temp -> info;
     free(temp);
     return deleted;
    }
    else
    {
      while(temp -> next != NULL)
       {
temp1 = temp;
temp = temp ->next;
       }
      temp1 -> next = NULL;
      deleted = temp -> info;
      free(temp);
      return deleted;
    }
  }
  else
   {
    printf("\nList is empty.");
    return NULL;
   }
}

void traverse_list(struct node **h)
{
 struct node *temp = NULL;
 printf("\nCurrent status of List : \n");
 temp = (*h);
 printf("\n*-->");
 if((*h) != NULL)