C Program Doubly Linked List | simple c program examples

What is c programming?

C programming is a general-purpose computer programming language developed in 1972 by Dennis Ritchie at the Bell Telephone Laboratories for use with the Unix operating system.
Although C programming was designed for implementing system software,It is also widely used for developing portable application software.
C programming is one of the most popular programming languages of all time and there are very few computer architectures for which a C compiler does not exist. C programming has greatly influenced many other popular programming languages.

tutorial for c,c examples source code,simple examples of c programs,simple c program examples


Bellow is c program example for c programming practice

C source codes for how to create Doubly Linked List In C

/***************************
      author-Nikunj v Gandhi
      from-gujarat(surat)
      Web Developer(ZCE)
      email-nik_gandhi007@yahoo.com
 http://my-source-codes.blogspot.com/
      Description:Doubly linked list using c program
      ******************************************** */
    #include<conio.h>
    #include<stdio.h>
    #include<malloc.h>
    struct link
      {
 int data;
 struct link *next;
 struct link *prev;
      }*start,*trav,*temp,*lright,*lleft,*t;
    void create()
      {
 int k=1,i=0;
 while(k==1)
   {
      temp=malloc(sizeof(struct link *));
      if(temp==NULL)
        {
   printf("NOT ENOUGH MEMORY TO CREATE NODEnn");
   exit();
  }
       printf("Enter data?");
       scanf("%d",&temp->data);
       temp->next=NULL;
       temp->prev=NULL;
       if(start==NULL)
   {
     start=temp;
     lleft=temp;
     lright=temp;
     trav=start;
   }
        else
    {
      lright->next=temp;
      lright=lright->next;
      if(i==0)
         {
    lleft->prev=NULL;
    i=1;
   }
       else
         {
     trav=trav->next;
     lleft->prev=trav;
     lleft=lleft->prev;
   }
   }
  printf("enter 1 for insert again?");
  scanf("%d",&k);
     }
    }
    void display()
      {

 trav=start;
 while(trav!=NULL)
   trav=trav->next;
 t=trav;
 while(t!=NULL)
   {
     printf("%dn",t->data);
     t=t->prev;
   }
      }
    void main()
      {
 int d,w=0;
 clrscr();
 while(w!=3)
   {
     printf("1 CREATE DOUBLY LIKED LISTn2 DISPLAYn3 EXITn");
     printf("Enter your choice?");
     scanf("%d",&w);
     if(w==1)
       create();
     else if(w==2)
       display();
     else if(w==3)
        exit();
    }
       }

Buy Me a Beer-If you are like this post

 If you does not have paypal account create free account create account

1 comment:

Super Bowl Commercials 2012 said...

Excellent pieces. Keep posting such kind of information on your blog. I really impressed by your blog.

Post a Comment