Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<stdlib.h>
- typedef struct node
- {
- int a;
- struct node*next;
- struct node*previous;
- } node;
- node*head;
- void display()
- {
- node*list=head;
- int k=list->a;
- while(list!=NULL)
- {
- if(k<list->a)
- {
- k=list->a;
- }
- list=list->next;
- }
- printf("\nMAX VALUE IS : %d\n",k);
- }
- void insert_at_end(int aN)
- {
- node*N=(node*)malloc(sizeof(node));
- N->a=aN;
- N->next=NULL;
- N->previous=NULL;
- node*list=head;
- if(head==NULL)
- {
- head=N;
- }
- else
- {
- while(list->next!=NULL)
- {
- list=list->next;
- N->previous=list;
- }
- list->next=N;
- N->next=NULL;
- N->previous=list;
- }
- }
- int main()
- {
- int i,x,af,l;
- head=NULL;
- printf("ENTER TOTAL INPUT :");
- scanf("%d",&l);
- for(i=0; i<l; i++)
- {
- scanf("%d",&af);
- insert_at_end(af);
- }
- display();
- }
Advertisement
Add Comment
Please, Sign In to add comment