write a C code To reverse a linked list

Answers were Sorted based on User's Feedback



write a C code To reverse a linked list..

Answer / sujith

include <stdio.h>

typedef struct list {
list_t *next;
int data;

}list_t;
list_t *list_reverse(list_t *list)
{
list_t *rlist = NULL;
while (list != NULL)
{
list_t *next = list->next;
list->next = rlist;
rlist = list;
list = next;
}
return rlist;
}
This will do the job.
Plese do verify this.
Sujith

Is This Answer Correct ?    27 Yes 12 No

write a C code To reverse a linked list..

Answer / haymo

sir u can reverse a linklist

Is This Answer Correct ?    16 Yes 2 No

Post New Answer

More C Interview Questions

a=0; b=(a=0)?2:3; a) What will be the value of b? why b) If in 1st stmt a=0 is replaced by -1, b=? c) If in second stmt a=0 is replaced by -1, b=?

6 Answers   Geometric Software,


What are register variables? What are the advantage of using register variables?

0 Answers   TISL,


What is #include called?

0 Answers  


what does data structure mean?

8 Answers  


What is a string?

0 Answers  






How can a process change an environment variable in its caller?

0 Answers  


what is pointer

1 Answers   TCS,


State the difference between x3 and x[3].

0 Answers   Aricent,


Write a C program to fill a rectangle using window scrolling

1 Answers  


What would happen to X in this expression: X += 15; (assuming the value of X is 5)

0 Answers  


dynamically allocate memory for linear array of n integers,store some elements in it and find some of them

1 Answers  


What is the use of bit field?

0 Answers  


Categories