programminginc.net

C Language Programming

  • Home
  • C Examples
Home > Data Structure C Programming Examples > Doubly linked list in data structure using C Program

Doubly linked list in data structure using C Program

 

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//

  • Singly Linked List Data Structure Program C
  • C program to insert a node in singly linked list
  • Doubly linked list in data structure using C Program
  • Insertion in doubly linked list data structure Using C Program
  • Deletion in doubly linked list data structure Using C Program

Copyright © 2021  programminginc.net