Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<stdlib.h>
- typedef struct node
- {
- int a;
- char s[20];
- struct node *next;
- struct node *prev;
- } node;
- node *head=NULL,*tail=NULL;
- void displaylst()
- {
- int ch;
- node *list=tail;
- if(head==NULL)
- {
- printf("NO Data Available!!\n\n ");
- }
- else
- {
- while(list!=NULL)
- {
- printf("\nName: %s\n",list->s);
- printf("Age: %d\n\n",list->a);
- list=list->prev;
- }
- }
- printf(" 1.Menu\n");
- printf(" 2.Exit\n");
- printf("Press Any Option:");
- scanf("%d",&ch);
- switch(ch)
- {
- case 1:
- {
- menu();
- }
- case 2:
- {
- exit(0);
- }
- default:
- {
- printf("You Choose Wrong Option!!\a\n\n");
- menu();
- break;
- }
- }
- }
- void displayfrst()
- {
- int ch;
- node *list=head;
- if(head==NULL)
- {
- printf(" NO Data Available!!\n\n ");
- }
- else
- {
- while(list!=NULL)
- {
- printf("\nName: %s\n",list->s);
- printf("Age: %d\n\n",list->a);
- list=list->next;
- }
- }
- printf(" 1.Menu\n");
- printf(" 2.Exit\n");
- printf("Press Any Option:");
- scanf("%d",&ch);
- switch(ch)
- {
- case 1:
- {
- menu();
- }
- case 2:
- {
- exit(0);
- }
- default:
- {
- printf("You Choose Wrong Option!!\a\n\n");
- menu();
- break;
- }
- }
- }
- void display()
- {
- int ch,n;
- printf(" 1.Display 1st To Last\n");
- printf(" 2.Display Last To 1st\n");
- printf("Choose Any Option:");
- scanf("%d",&n);
- switch(n)
- {
- case 1:
- {
- displayfrst();
- break;
- }
- case 2:
- {
- displaylst();
- break;
- }
- default:
- {
- printf("You Choose Wrong Option!!\a\n\n");
- menu();
- break;
- }
- }
- }
- void searchpos()
- {
- int ch,n;
- node *list=head;
- printf("Enter Your Position:");
- scanf("%d",&n);
- if(n==1)
- {
- printf("Name: %s\n",list->s);
- printf("Age: %d\n\n",list->a);
- }
- else
- {
- n=n-2;
- while(n!=0&&list->next!=NULL)
- {
- list=list->next;
- n--;
- }
- if(list->next==NULL)
- {
- printf("No Information Available!!\n\n");
- }
- else
- {
- printf("Name: %s\n",list->next->s);
- printf("Age: %d\n\n",list->next->a);
- }
- }
- printf(" 1.Menu\n");
- printf(" 2.Exit\n");
- printf("Press Any Option:");
- scanf("%d",&ch);
- switch(ch)
- {
- case 1:
- {
- menu();
- }
- case 2:
- {
- exit(0);
- }
- default:
- {
- printf("You Choose Wrong Option!!\a\n\n");
- menu();
- break;
- }
- }
- }
- void searchval()
- {
- node *list=head;
- int ch,v;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement