Advertisement
SOIKAT

Untitled

Mar 2nd, 2020
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<stdlib.h>
  3. #include<string.h>
  4. struct node
  5. {
  6. int data;
  7. char Name[40];
  8. struct node* link;
  9. };
  10. struct node* head=NULL;
  11. void insert()
  12. {
  13. struct node* temp=(struct node*)malloc(sizeof(struct node));
  14.  
  15.  
  16. temp->data=1001;
  17. strcpy(temp->Name,"Karim");
  18. temp->link=NULL;
  19. head=temp;
  20. struct node* temp1=(struct node*)malloc(sizeof(struct node));
  21. temp1->data=1002;
  22. strcpy(temp1->Name,"Rahim");
  23. temp1->link=NULL;
  24. struct node*p=head;
  25. p->link=temp1;
  26.  
  27. }
  28. display()
  29. {
  30. struct node* p=head;
  31. printf("1st-ID = %d ",p->data);
  32. printf("Name: %s ",p->Name);
  33. p=p->link;
  34. printf(" 2nd-ID = %d ",p->data);
  35. printf("Name: %s ",p->Name);
  36. }
  37. int main()
  38. {
  39. insert();
  40. display();
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement