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 |
Difference between pass by reference and pass by value?
largest Of three Number using without if condition?
Can we declare function inside main?
Explain how do you print only part of a string?
List a few unconditional control statement in c.
What is the modulus operator?
What is the relation between # and include<stdio.h>
What are the back slash character constants or escape sequence charactersavailable in c?
Why is c so important?
Explain what does it mean when a pointer is used in an if statement?
what is a NULL pointer?
what is diognisis?