Insertion At Last in doubly linked list

Algorithm

InsertAtEndDll(info,prev,next,start,end)
1.create a new node and address in assigned to ptr.
2.check[overflow] if(ptr=NULL)
      write:overflow and exit 
3.set Info[ptr]=item;
4.if(start=NULL) 
      set prev[ptr] = next[ptr] = NULL 
      set start = end = ptr
  else
      set prev[ptr] = end
      next[end] = ptr
      set ptr[next] = NULL
      set end = ptr
      [end if]
5.Exit.          






Fuction For Insert at Last

void insertAtlast(node **start,node **end,int item )
{
	node *ptr;
	ptr=(node*)malloc(sizeof(node));
	ptr->info=item;
	if(*start==NULL)
	{
		ptr->prev = ptr->next = NULL ;
        *start = *end = ptr ;
	}
	else
	{
		ptr->prev = *end;
        (*end)->next = ptr ;
		ptr->next= NULL;
		(*end)=ptr;
	}
}



C programe for insertion at begning in dubly linked list

#include<stdio.h>
#include<malloc.h>
#include<conio.h>
typedef struct Node
{
	struct Node *prev;
	int info ;
	struct Node *next;
}node;

void createdub(node**,node**);
void insertAtlast(node **,node**,int);
void display(node *);

void main()
{
	int ch, item, pos;
	node *start ,*end ;
	start = end = NULL;
	clrscr();
	createdub(&start,&end);
	printf("\nThe list is : ");
	display(start);
	printf("\n\nEnter the item to be inserted at last:");
	scanf("%d",&item);
	insertAtlast(&start,&end,item);
	printf("\nNow the list is : ");
	display(start);
	getch();
}
void createdub(node **start,node **end)
{    
	int i,item ,k=1;
	printf("\nEnter number of node: ");
	scanf("%d",&i);
	while(i)
	{   node *ptr;
		printf("\nEnter the info for node %d : ",k);
		scanf("%d",&item);
		ptr=(node*)malloc(sizeof(node));
		ptr->info=item;
		if(*start==NULL)
		{
			ptr->prev = ptr->next = NULL ;
			*start = *end = ptr ;
		}
		else
		{
			ptr->prev = *end;
        	(*end)->next = ptr ;
			ptr->next= NULL;
			(*end)=ptr;
		}
		i--;
		k++;
	}
}
void insertAtlast(node **start,node **end,int item )
{
	node *ptr;
	ptr=(node*)malloc(sizeof(node));
	ptr->info=item;
	if(*start==NULL)
	{
		ptr->prev = ptr->next = NULL ;
        *start = *end = ptr ;
	}
	else
	{
		ptr->prev = *end;
        (*end)->next = ptr ;
		ptr->next= NULL;
		(*end)=ptr;
	}
}

void display(node *start)
{
     while(start !=NULL)
     { 
		printf("\t %d",start->info);
		start = start->next;
     }
}

Output






Quantitative Aptitude
Reasoning
Programming
Interview