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
Write a program to swap two numbers without using a temporary variable?
Difference between Function to pointer and pointer to function
What is scanf () in c?
What is the function of volatile in c language?
Is c procedural or functional?
Find the second largest element in an array with minimum no of comparisons and give the minimum no of comparisons needed on an array of size N to do the same.
What is pointer to pointer in c with example?
What is the size of empty structure in c?
What is the use of f in c?
why programs in c are running with out #include
Array is an lvalue or not?
Did c have any year 2000 problems?
What does volatile do?
Explain how can you tell whether two strings are the same?
What is the equivalent code of the following statement in WHILE LOOP format?