C Program to Created Doubly Linked List using pointers
//C Program to create doubly linked list #// #include<stdio.h> #include<conio.h> #include<alloc.h> struct doublelist { int info; struct doublelist *next, *prev; }; typedef struct doublelist node; node* makenode(int); void display(node*); main() { node *head, *p, *z; int x; char c='y'; clrscr(); printf("Enter the number"); scanf("%d", &x); head=makenode(x); p=head; printf("Do you wnat to continue"); fflush(stdin); scanf("%c", &c); while(c!='n') { printf("Enter the number"); scanf("%d", &x); z=makenode(x); p->next=z; z->prev=p; p=z; printf("\n\nDo you want to continue"); fflush(stdin); scanf("%c", &c); } printf("\n\nThe linked list is "); display(head); getch(); return 0; } node* makenode(int x) { node *z; z=(node*)malloc(sizeof(node)); z->info=x; z->prev=NULL; z->next=NULL; return z; } void display(node *head) {node *p, *z; p=head; while(p!=NULL) {z=p; printf("\t%d", p->info); p=p->next; } while(z!=NULL) {printf("\t%d", z->info); z=z->prev; } } //end of program//