Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<stdlib.h>
- struct Node{
- int data;
- struct Node* link;
- };
- struct Node* root=NULL;
- int length;
- void Append()
- {
- struct Node* temp;
- temp=(struct Node*)malloc(sizeof(struct Node*));
- printf("**Enter Node Data ** : ");
- scanf("%d",&temp->data);
- temp->link=NULL;
- if(root==NULL)
- {
- temp=root;
- }
- else
- {
- struct Node* temp1;
- temp1=root;
- while(temp1!=NULL)
- {
- temp1=temp1->link;
- }
- temp=temp1;
- }
- }
- void AddAtBegin()
- {
- }
- void AddAtAfter()
- {
- }
- void Delete()
- {
- }
- int Length()
- {
- }
- void Display()
- {
- struct Node* temp;
- temp=root;
- if(temp==NULL)
- {
- printf("\n\n***List is Empty***\n\n");
- }
- else
- {
- while(temp!=NULL)
- {
- printf("%d-->",temp->data);
- temp=temp->link;
- }
- printf("\n\n");
- }
- }
- void Append(void);
- void AddAtBegin(void);
- void AddAtAfter(void);
- void Delete(void);
- int Length(void);
- void Display(void);
- void main()
- {
- int ch;
- while(1)
- {
- printf("***Single Linked List Operation***\n\n");
- printf("1. Append\n");
- printf("2. Add At Begin\n");
- printf("3. Add At After\n");
- printf("4. Delete\n");
- printf("5. Length\n");
- printf("6. Display\n");
- printf("7. Quit\n");
- printf("Enter your choice: ");
- scanf("%d",&ch);
- switch(ch)
- {
- case 1: Append();
- break;
- case 2: AddAtBegin();
- break;
- case 3: AddAtAfter();
- break;
- case 4: Delete();
- break;
- case 5: Length();
- break;
- case 6: Display();
- break;
- case 7: exit(1);
- default: printf("--Invalid Input--\n\n");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement