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 |
can anyone suggest some site name..where i can get some good data structure puzzles???
swap 2 numbers without using third variable?
What is #line used for?
Explain what is operator promotion?
What are the difference between a free-standing and a hosted environment?
any restrictions have on the number of 'return' statements that may be present in a function. a) no restriction b) only 2 return statements c) only 1 return statements d) none of the above
write a c program for greatest of three numbers without using if statment
int j =15,i; for (i=1; 1<5; ++i) {printf ("%d%d ",j,i); j = j-3; }
what is pointer?
13 Answers HCL, TCS,
How can I manipulate individual bits?
Explain following declaration int *P(void); and int (*p)(char *a);
How to add two numbers with using function?