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
How to explain the final year project as a fresher please answer with sample project
List the difference between a 'copy constructor' and a 'assignment operator' in C?
what are enumerations in C
in iso what are the common technological language?
What is maximum size of array in c?
What is 1d array in c?
What is the difference between int main and void main?
What is static function in c?
Why static is used in c?
How to draw the flowchart for structure programs?
Why is this loop always executing once?
Is c language still used?
List the difference between a "copy constructor" and a "assignment operator"?
How many types of sorting are there in c?
Here is a good puzzle: how do you write a program which produces its own source code as output?