SHARE
TWEET

Untitled

a guest Aug 20th, 2019 67 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. if(pos >= 1)
  2. {
  3. newNode->next = start;
  4. start = newNode;
  5. }
  6.      
  7. newNode = (node*)malloc(sizeof(node));
  8. printf("nEnter the data to insert : ");
  9. scanf("%d",&newNode->data);
  10. newNode->next = NULL;
  11. printf("nEnter the position : ");
  12. scanf("%d",&pos);
  13.  
  14. if(pos == 1){
  15.     newNode->next = start;
  16.     start = newNode;
  17. }
  18.  
  19. else{
  20.     for(temp = start,i = 1;temp != NULL;temp = temp->next,i++){
  21.         if(i == (pos - 1)){
  22.             newNode->next = temp->next;
  23.             temp->next = newNode;
  24.             break;
  25.         }
  26.     }
  27. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top