writw a program to insert an element in the begning of a
doubly linked list
Answer Posted / 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 View All Answers
Tell me with an example the self-referential structure?
How do you redirect a standard stream?
What is unsigned int in c?
how to capitalise first letter of each word in a given string?
Is r written in c?
write a c program thal will find all sequences of length N that produce the sum is Zero, print all possible solutions?
What is derived datatype in c?
Where define directive used?
Suggesting that there can be 62 seconds in a minute?
What is the difference between array_name and &array_name?
Should I learn data structures in c or python?
What does do in c?
Explain the difference between malloc() and calloc() in c?
Is anything faster than c?
What is the purpose of the statement: strcat (S2, S1)?