Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<stdlib.h>
- #include<conio.h>
- struct node
- {
- int data;
- struct node *link;
- };
- struct node *start =NULL;
- void enq_first()
- {
- struct node *temp;
- temp=(struct node*)malloc(sizeof(struct node));
- printf("\nEnter value to insert : ");scanf("%d",&temp->data);
- //temp->data=x;
- printf("Inserted value is : %d",temp->data);
- if(start==NULL)
- {temp->link=NULL;
- start=temp;}
- else
- {
- temp->link=start;
- start=temp;
- }
- }
- /*void enq_int(int x)
- {
- int i,pos;
- struct node *temp;
- struct node *temp1;
- temp=(struct node*)malloc(sizeof(struct node));
- temp1=(struct node*)malloc(sizeof(struct node));
- temp->data=x;
- printf("Enter the position to enter the data : ");scanf("%d",&pos);
- temp1=start;
- for(i=1;i<pos;i++)
- {
- temp1=temp1->link;
- }
- temp->link=temp1->link;
- temp1->link=temp;
- return;
- }
- */
- /*void enq_end(int x)
- {
- struct node *temp;
- struct node *temp1;
- temp=(struct node*)malloc(sizeof(struct node));
- temp1=(struct node*)malloc(sizeof(struct node));
- temp->data=x;
- temp->link=NULL;
- if(start==NULL){start=temp;return;}
- temp1=start;
- while(temp1->link!=NULL){temp1=temp1->link;}
- temp1->link=temp;
- return;
- }
- */
- void disp()
- {
- struct node *temp1;
- temp1=(struct node*)malloc(sizeof(struct node));
- if(start==NULL){printf("\nList is Empty!!");}
- else
- {
- temp1=start;
- printf("The elements in the list : ");
- while(temp1->link!=NULL)
- {
- printf(" %d, ",temp1->data);
- temp1=temp1->link;
- }
- }
- }
- int main()
- {
- int pos;
- int choice,value;
- int count=0;
- while(1)
- {
- printf("\n\n\nOPTIONS MENU");
- printf("\n1.Insert at Beginning \n2.Insert at Specified Position");
- printf("\n3.Insert at End\n4.Display\n5.EXIT");
- printf("\nSelect your decision : ");
- scanf("%d",&choice);
- switch(choice)
- {
- case 1:
- enq_first();break;
- /*case 2:
- printf("\nEnter value to insert : ");scanf("%d",&value);
- enq_int(value);break;
- case 3:
- printf("\nEnter value to insert : ");scanf("%d",&value);
- enq_end(value);break;*/
- case 4:
- disp();break;
- case 5: exit(0);
- default:
- printf("Wrong Selection!");
- }
- }
- getch();
- return 0;
- }
- #include<stdio.h>
- #include<stdlib.h>
- #include<conio.h>
- struct node
- {
- int data;
- struct node *link;
- };
- struct node *start =NULL;
- void enq_first()
- {
- struct node *temp;
- temp=(struct node*)malloc(sizeof(struct node));
- printf("\nEnter value to insert : ");scanf("%d",&temp->data);
- //temp->data=x;
- printf("Inserted value is : %d",temp->data);
- if(start==NULL)
- {temp->link=NULL;
- start=temp;}
- else
- {
- temp->link=start;
- start=temp;
- }
- }
- /*void enq_int(int x)
- {
- int i,pos;
- struct node *temp;
- struct node *temp1;
- temp=(struct node*)malloc(sizeof(struct node));
- temp1=(struct node*)malloc(sizeof(struct node));
- temp->data=x;
- printf("Enter the position to enter the data : ");scanf("%d",&pos);
- temp1=start;
- for(i=1;i<pos;i++)
- {
- temp1=temp1->link;
- }
- temp->link=temp1->link;
- temp1->link=temp;
- return;
- }
- */
- /*void enq_end(int x)
- {
- struct node *temp;
- struct node *temp1;
- temp=(struct node*)malloc(sizeof(struct node));
- temp1=(struct node*)malloc(sizeof(struct node));
- temp->data=x;
- temp->link=NULL;
- if(start==NULL){start=temp;return;}
- temp1=start;
- while(temp1->link!=NULL){temp1=temp1->link;}
- temp1->link=temp;
- return;
- }
- */
- void disp()
- {
- struct node *temp1;
- temp1=(struct node*)malloc(sizeof(struct node));
- if(start==NULL){printf("\nList is Empty!!");}
- else
- {
- temp1=start;
- printf("The elements in the list : ");
- while(temp1->link!=NULL)
- {
- printf(" %d, ",temp1->data);
- temp1=temp1->link;
- }
- }
- }
- int main()
- {
- int pos;
- int choice,value;
- int count=0;
- while(1)
- {
- printf("\n\n\nOPTIONS MENU");
- printf("\n1.Insert at Beginning \n2.Insert at Specified Position");
- printf("\n3.Insert at End\n4.Display\n5.EXIT");
- printf("\nSelect your decision : ");
- scanf("%d",&choice);
- switch(choice)
- {
- case 1:
- enq_first();break;
- /*case 2:
- printf("\nEnter value to insert : ");scanf("%d",&value);
- enq_int(value);break;
- case 3:
- printf("\nEnter value to insert : ");scanf("%d",&value);
- enq_end(value);break;*/
- case 4:
- disp();break;
- case 5: exit(0);
- default:
- printf("Wrong Selection!");
- }
- }
- getch();
- return 0;
- }
- #include<stdio.h>
- #include<stdlib.h>
- #include<conio.h>
- struct node
- {
- int data;
- struct node *link;
- };
- struct node *start =NULL;
- void enq_first()
- {
- struct node *temp;
- temp=(struct node*)malloc(sizeof(struct node));
- printf("\nEnter value to insert : ");scanf("%d",&temp->data);
- //temp->data=x;
- printf("Inserted value is : %d",temp->data);
- if(start==NULL)
- {temp->link=NULL;
- start=temp;}
- else
- {
- temp->link=start;
- start=temp;
- }
- }
- /*void enq_int(int x)
- {
- int i,pos;
- struct node *temp;
- struct node *temp1;
- temp=(struct node*)malloc(sizeof(struct node));
- temp1=(struct node*)malloc(sizeof(struct node));
- temp->data=x;
- printf("Enter the position to enter the data : ");scanf("%d",&pos);
- temp1=start;
- for(i=1;i<pos;i++)
- {
- temp1=temp1->link;
- }
- temp->link=temp1->link;
- temp1->link=temp;
- return;
- }
- */
- /*void enq_end(int x)
- {
- struct node *temp;
- struct node *temp1;
- temp=(struct node*)malloc(sizeof(struct node));
- temp1=(struct node*)malloc(sizeof(struct node));
- temp->data=x;
- temp->link=NULL;
- if(start==NULL){start=temp;return;}
- temp1=start;
- while(temp1->link!=NULL){temp1=temp1->link;}
- temp1->link=temp;
- return;
- }
- */
- void disp()
- {
- struct node *temp1;
- temp1=(struct node*)malloc(sizeof(struct node));
- if(start==NULL){printf("\nList is Empty!!");}
- else
- {
- temp1=start;
- printf("The elements in the list : ");
- while(temp1->link!=NULL)
- {
- printf(" %d, ",temp1->data);
- temp1=temp1->link;
- }
- }
- }
- int main()
- {
- int pos;
- int choice,value;
- int count=0;
- while(1)
- {
- printf("\n\n\nOPTIONS MENU");
- printf("\n1.Insert at Beginning \n2.Insert at Specified Position");
- printf("\n3.Insert at End\n4.Display\n5.EXIT");
- printf("\nSelect your decision : ");
- scanf("%d",&choice);
- switch(choice)
- {
- case 1:
- enq_first();break;
- /*case 2:
- printf("\nEnter value to insert : ");scanf("%d",&value);
- enq_int(value);break;
- case 3:
- printf("\nEnter value to insert : ");scanf("%d",&value);
- enq_end(value);break;*/
- case 4:
- disp();break;
- case 5: exit(0);
- default:
- printf("Wrong Selection!");
- }
- }
- getch();
- return 0;
- }
- #include<stdio.h>
- #include<stdlib.h>
- #include<conio.h>
- struct node
- {
- int data;
- struct node *link;
- };
- struct node *start =NULL;
- void enq_first()
- {
- struct node *temp;
- temp=(struct node*)malloc(sizeof(struct node));
- printf("\nEnter value to insert : ");scanf("%d",&temp->data);
- //temp->data=x;
- printf("Inserted value is : %d",temp->data);
- if(start==NULL)
- {temp->link=NULL;
- start=temp;}
- else
- {
- temp->link=start;
- start=temp;
- }
- }
- /*void enq_int(int x)
- {
- int i,pos;
- struct node *temp;
- struct node *temp1;
- temp=(struct node*)malloc(sizeof(struct node));
- temp1=(struct node*)malloc(sizeof(struct node));
- temp->data=x;
- printf("Enter the position to enter the data : ");scanf("%d",&pos);
- temp1=start;
- for(i=1;i<pos;i++)
- {
- temp1=temp1->link;
- }
- temp->link=temp1->link;
- temp1->link=temp;
- return;
- }
- */
- /*void enq_end(int x)
- {
- struct node *temp;
- struct node *temp1;
- temp=(struct node*)malloc(sizeof(struct node));
- temp1=(struct node*)malloc(sizeof(struct node));
- temp->data=x;
- temp->link=NULL;
- if(start==NULL){start=temp;return;}
- temp1=start;
- while(temp1->link!=NULL){temp1=temp1->link;}
- temp1->link=temp;
- return;
- }
- */
- void disp()
- {
- struct node *temp1;
- temp1=(struct node*)malloc(sizeof(struct node));
- if(start==NULL){printf("\nList is Empty!!");}
- else
- {
- temp1=start;
- printf("The elements in the list : ");
- while(temp1->link!=NULL)
- {
- printf(" %d, ",temp1->data);
- temp1=temp1->link;
- }
- }
- }
- int main()
- {
- int pos;
- int choice,value;
- int count=0;
- while(1)
- {
- printf("\n\n\nOPTIONS MENU");
- printf("\n1.Insert at Beginning \n2.Insert at Specified Position");
- printf("\n3.Insert at End\n4.Display\n5.EXIT");
- printf("\nSelect your decision : ");
- scanf("%d",&choice);
- switch(choice)
- {
- case 1:
- enq_first();break;
- /*case 2:
- printf("\nEnter value to insert : ");scanf("%d",&value);
- enq_int(value);break;
- case 3:
- printf("\nEnter value to insert : ");scanf("%d",&value);
- enq_end(value);break;*/
- case 4:
- disp();break;
- case 5: exit(0);
- default:
- printf("Wrong Selection!");
- }
- }
- getch();
- return 0;
- }
- #include<stdio.h>
- #include<stdlib.h>
- #include<conio.h>
- struct node
- {
- int data;
- struct node *link;
- };
- struct node *start =NULL;
- void enq_first()
- {
- struct node *temp;
- temp=(struct node*)malloc(sizeof(struct node));
- printf("\nEnter value to insert : ");scanf("%d",&temp->data);
- //temp->data=x;
- printf("Inserted value is : %d",temp->data);
- if(start==NULL)
- {temp->link=NULL;
- start=temp;}
- else
- {
- temp->link=start;
- start=temp;
- }
- }
- /*void enq_int(int x)
- {
- int i,pos;
- struct node *temp;
- struct node *temp1;
- temp=(struct node*)malloc(sizeof(struct node));
- temp1=(struct node*)malloc(sizeof(struct node));
- temp->data=x;
- printf("Enter the position to enter the data : ");scanf("%d",&pos);
- temp1=start;
- for(i=1;i<pos;i++)
- {
- temp1=temp1->link;
- }
- temp->link=temp1->link;
- temp1->link=temp;
- return;
- }
- */
- /*void enq_end(int x)
- {
- struct node *temp;
- struct node *temp1;
- temp=(struct node*)malloc(sizeof(struct node));
- temp1=(struct node*)malloc(sizeof(struct node));
- temp->data=x;
- temp->link=NULL;
- if(start==NULL){start=temp;return;}
- temp1=start;
- while(temp1->link!=NULL){temp1=temp1->link;}
- temp1->link=temp;
- return;
- }
- */
- void disp()
- {
- struct node *temp1;
- temp1=(struct node*)malloc(sizeof(struct node));
- if(start==NULL){printf("\nList is Empty!!");}
- else
- {
- temp1=start;
- printf("The elements in the list : ");
- while(temp1->link!=NULL)
- {
- printf(" %d, ",temp1->data);
- temp1=temp1->link;
- }
- }
- }
- int main()
- {
- int pos;
- int choice,value;
- int count=0;
- while(1)
- {
- printf("\n\n\nOPTIONS MENU");
- printf("\n1.Insert at Beginning \n2.Insert at Specified Position");
- printf("\n3.Insert at End\n4.Display\n5.EXIT");
- printf("\nSelect your decision : ");
- scanf("%d",&choice);
- switch(choice)
- {
- case 1:
- enq_first();break;
- /*case 2:
- printf("\nEnter value to insert : ");scanf("%d",&value);
- enq_int(value);break;
- case 3:
- printf("\nEnter value to insert : ");scanf("%d",&value);
- enq_end(value);break;*/
- case 4:
- disp();break;
- case 5: exit(0);
- default:
- printf("Wrong Selection!");
- }
- }
- getch();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement