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 |
How to write a multi-statement macro?
Are comments included during the compilation stage and placed in the EXE file as well?
What is the function of volatile in c language?
How do I copy files?
What is table lookup in c?
Which is the best sort method for library management?
Explain what is wrong in this statement?
do u print this format '(((())))'. This brackets is based on user input like 4 or 5 or 6,without using any loop's?
in malloc and calloc which one is fast and why?
Difference between exit() and _exit() function?
Write a C program that reads a series of strings and prints only those ending in "ed"
Write a program which take a integer from user and tell whether the given variable is squar of some number or not. eg: is this number is 1,4,9,16... or not