<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>c lab prgrams | Student Projects</title>
	<atom:link href="https://studentprojects.in/tag/c-lab-prgrams/feed/" rel="self" type="application/rss+xml" />
	<link>https://studentprojects.in</link>
	<description>Microcontroller projects, Circuit Diagrams, Project Ideas</description>
	<lastBuildDate>Sat, 09 Jun 2012 16:51:25 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.1.7</generator>
	<item>
		<title>Program for Doubly Linked List Operations</title>
		<link>https://studentprojects.in/software-development/c-tutorials/c/data-structures-c/program-for-doubly-linked-list-operations/</link>
					<comments>https://studentprojects.in/software-development/c-tutorials/c/data-structures-c/program-for-doubly-linked-list-operations/#respond</comments>
		
		<dc:creator><![CDATA[Ansten Lobo]]></dc:creator>
		<pubDate>Sat, 09 Jun 2012 16:51:25 +0000</pubDate>
				<category><![CDATA[Data Structures]]></category>
		<category><![CDATA[c program]]></category>
		<category><![CDATA[Insert]]></category>
		<category><![CDATA[Delete]]></category>
		<category><![CDATA[doubly linked list]]></category>
		<category><![CDATA[Display]]></category>
		<category><![CDATA[c lab prgrams]]></category>
		<guid isPermaLink="false">http://studentprojects.in/?p=3315</guid>

					<description><![CDATA[<p>Program for Doubly Linked List Operations – Insert (Front, Before), Delete, Display Source: Dr. G T Raju, Professor &#038; Head, Dept. of CSE, RNSIT #include typedef struct dnode { int data; struct dnode *next,*prev; }DNODE; DNODE *InsFront(DNODE *, int); DNODE *InsBefore(DNODE *, int,int); DNODE *DelNode(DNODE *, int); void Display(DNODE *); main() { DNODE *start=NULL; /*</p>
<p>The post <a href="https://studentprojects.in/software-development/c-tutorials/c/data-structures-c/program-for-doubly-linked-list-operations/">Program for Doubly Linked List Operations</a> first appeared on <a href="https://studentprojects.in">Student Projects</a>.</p>]]></description>
										<content:encoded><![CDATA[<p>Program for Doubly Linked List Operations – Insert (Front, Before), Delete, Display<br />
Source: Dr. G T Raju, Professor &#038; Head, Dept. of CSE, RNSIT</p>
<pre lang="C" line="1">
#include <stdlib.h>
typedef struct dnode
{
    int data;
    struct dnode *next,*prev;
}DNODE;

DNODE *InsFront(DNODE *, int);
DNODE *InsBefore(DNODE *, int,int);
DNODE *DelNode(DNODE *, int);
void Display(DNODE *);

main()
{
    DNODE *start=NULL;		 /* Main Program */
    int opn,elem,info,n,i;
    do
    {
        clrscr();
        printf("\n ### Doubly Linked List Operations ### \n\n");
        printf("\n Press 1-Creation with front Insertion");
        printf("\n       2-Insert Before a Given Node");
        printf("\n       3-Delete a Given Node");
        printf("\n       4-Display");
        printf("\n       5-Exit\n");
        printf("\n       Your option ? ");
        scanf("%d",&opn);
        switch(opn)
        {
        case 1:
            printf("\n\nHow Many Nodes ?");
            scanf("%d",&n);
            for(i=1;i<=n;i++)
            {
                printf("\nRead the Data for Node %d ?",i);
                scanf("%d",&#038;elem);
                start=InsFront(start,elem);
            }
            printf("\nDoubly Linked list with %d nodes is ready toUse!!\n",n);
            break;
        case 3: printf(" Read the Info of the Node to be deleted ? ");
            scanf("%d",&#038;info);
            start=DelNode(start,info);
            break;
        case 2: printf(" Read the Data for New node\n");
            scanf("%d",&#038;elem);
            printf(" Read the Info of the Node(to the left of which new node tobe inserted ? ");
            scanf("%d",&#038;info);
            start=InsBefore(start,elem,info);
            break;
        case 4: printf(" Doubly Linked List is \n");
            Display(start); break;
        case 5: printf("\n\n Terminating \n\n"); break;
        default: printf("\n\nInvalid Option !!! Try Again !! \n\n");
            break;
        }
        printf("\n\n\n\n  Press a Key to Continue . . . ");
        getch();
    }while(opn != 5);
}

DNODE *InsFront(DNODE *start, int elem)
{
    DNODE *temp;
    temp=(DNODE *)malloc(sizeof(DNODE));
    if( temp == NULL)
    { printf(" Out of Memory !! Overflow !!!");
    return(start);
    }
    else
    {
        temp->data=elem;
        temp->prev=NULL;
        temp->next=start;
        start->prev=temp;
        printf(" New Node has been inserted at Front Successfully !!");
        return(temp);
    }
}

DNODE *InsBefore(DNODE *start, int elem,int info)
{
    DNODE *temp,*t;
    temp=(DNODE *)malloc(sizeof(DNODE));
    if( temp == NULL)
    { printf(" Out of Memory !! Overflow !!!");
    return(start);
    }
    else
    {
        temp->data=elem;
        temp->next=NULL;
        temp->prev=NULL;

        if(start->data == info)    /* Front Insertion */
        { temp->next=start;
        start->prev=temp;
        return(temp);
        }
        else
        {
            t=start;
            while( t != NULL && t->data != info)
                t=t->next;
            if(t->data == info) /* Node found */
            {
                temp->next=t;
                temp->prev=t->prev;
                t->prev->next=temp;
                t->prev=temp;
            }
            else
                printf(" Node not found,Invalid Info !!!");
            return(start);
        }
    }
}

DNODE *DelNode(DNODE *start, int info)
{
    DNODE *t;
    if( start ==  NULL) { printf(" Underflow!!!"); return(start); }
    else
    { t=start;
    if(start->data == info)    /* Front Deletion */
    { start=start->next;
    start->prev=NULL;
    t->next=NULL;
    free(t);
    return(start);
    }
    else
    {
        while( t != NULL && t->data != info)
            t=t->next;
        if(t->data == info) /* node to be deleted  found*/
        {
            t->prev->next=t->next;
            t->next->prev=t->prev;
            t->next=t->prev=NULL;
            free(t);
        }
        else
            printf("Node not found, Invalid Info !!");
        return(start);
    }
    }
}
void Display(DNODE *start)
{ 
	DNODE *t;
	if( start == NULL) printf("Empty List\n");
	else
	{
		t=start;
		printf("Forward Traversal \n\n Start->");
		while(t)
		{
			printf("[%d]->",t->data);
			t=t->next;
		}
		printf("Null\n");
	}
}
</pre><p>The post <a href="https://studentprojects.in/software-development/c-tutorials/c/data-structures-c/program-for-doubly-linked-list-operations/">Program for Doubly Linked List Operations</a> first appeared on <a href="https://studentprojects.in">Student Projects</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://studentprojects.in/software-development/c-tutorials/c/data-structures-c/program-for-doubly-linked-list-operations/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
