writw a program to insert an element in the begning of a
doubly linked list



writw a program to insert an element in the begning of a doubly linked list..

Answer / mani

#include<stdio.h>

typedef struct node {
int data;
struct node *leftlink;
struct node *rightlink;
}node;

node *start=NULL;
node *tail=NULL;

void add_begin(node *);
main()
{

.......
.......

add_begin(start);

.......
.......
}

void add_begin(node *temp)
{
node *new_node=NULL;
int idata;
printf("enter the data part value: ");
scanf("%d",&idata);

if(start==NULL && tail==NULL )
{
new_node=(node *)malloc(sizeof(node));
new_node->data=idata;
new_node->leftlink=NULL;
new_node->rightlink=NULL;
start=new_node;
tail=new_node;
}
else
{
new_node=(node *)malloc(sizeof(node));
new_node->data=idata;
temp->leftlink=new_node;
new_node->rightlink=temp;
new_node->leftlink=NULL;
start=newnode;
}
}

Is This Answer Correct ?    3 Yes 0 No

Post New Answer

More C Interview Questions

What is a program?

0 Answers  


i got 75% in all semester am i eligible for your company

0 Answers   Infosys,


What are pragmas and what are they good for?

0 Answers  


What are the different data types in C?

0 Answers  


what is a non volatile key word in c language?

1 Answers  






write a c programming using command line argument,demonstrate set operation(eg;union,intersection,difference) example output is c:>setop 12 34 45 1 union 34 42 66 c:>setop 12 34 1 42 66 c:>setop 12 34 diff 12 56 67 78 setop 12 34

0 Answers  


What is the use of sizeof () in c?

0 Answers  


Distinguish between actual and formal arguments.

0 Answers  


main() { int a; a=++100; printf("%d",a); getch(); }

4 Answers  


Why we use break in c?

0 Answers  


Explain data types & how many data types supported by c?

0 Answers  


What is d'n in c?

0 Answers  


Categories