Advertisement
Guest User

Untitled

a guest
Feb 28th, 2020
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.02 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<stdlib.h>
  3.  
  4. struct Node{
  5. int data;
  6. struct Node* link;
  7.  
  8. };
  9.  
  10. struct Node* root=NULL;
  11. int length;
  12.  
  13. void Append()
  14. {
  15. struct Node* temp;
  16. temp=(struct Node*)malloc(sizeof(struct Node*));
  17.  
  18. printf("**Enter Node Data ** : ");
  19. scanf("%d",&temp->data);
  20. temp->link=NULL;
  21.  
  22. if(root==NULL)
  23. {
  24. temp=root;
  25. }
  26. else
  27. {
  28. struct Node* temp1;
  29. temp1=root;
  30.  
  31. while(temp1!=NULL)
  32. {
  33. temp1=temp1->link;
  34. }
  35. temp=temp1;
  36. }
  37.  
  38. }
  39. void AddAtBegin()
  40. {
  41.  
  42. }
  43. void AddAtAfter()
  44. {
  45.  
  46. }
  47. void Delete()
  48. {
  49.  
  50. }
  51. int Length()
  52. {
  53.  
  54. }
  55.  
  56. void Display()
  57. {
  58. struct Node* temp;
  59. temp=root;
  60. if(temp==NULL)
  61. {
  62. printf("\n\n***List is Empty***\n\n");
  63.  
  64. }
  65. else
  66. {
  67. while(temp!=NULL)
  68. {
  69.  
  70. printf("%d-->",temp->data);
  71. temp=temp->link;
  72. }
  73. printf("\n\n");
  74.  
  75. }
  76.  
  77. }
  78.  
  79.  
  80. void Append(void);
  81. void AddAtBegin(void);
  82. void AddAtAfter(void);
  83. void Delete(void);
  84. int Length(void);
  85. void Display(void);
  86.  
  87.  
  88. void main()
  89. {
  90. int ch;
  91. while(1)
  92. {
  93. printf("***Single Linked List Operation***\n\n");
  94. printf("1. Append\n");
  95. printf("2. Add At Begin\n");
  96. printf("3. Add At After\n");
  97. printf("4. Delete\n");
  98. printf("5. Length\n");
  99. printf("6. Display\n");
  100. printf("7. Quit\n");
  101.  
  102. printf("Enter your choice: ");
  103. scanf("%d",&ch);
  104.  
  105. switch(ch)
  106. {
  107. case 1: Append();
  108. break;
  109. case 2: AddAtBegin();
  110. break;
  111. case 3: AddAtAfter();
  112. break;
  113. case 4: Delete();
  114. break;
  115. case 5: Length();
  116. break;
  117. case 6: Display();
  118. break;
  119. case 7: exit(1);
  120.  
  121. default: printf("--Invalid Input--\n\n");
  122. }
  123. }
  124. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement