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

how to impliment 2 or more stacks in a single dimensional array ?

1 Answers   iFlex, Microsoft,


What is the difference between volatile and const volatile?

0 Answers  


write a program to display the numbers having digit 9 in the given range from 1 to 100

1 Answers  


Explain how can I read and write comma-delimited text?

0 Answers  


to write a program, that finds the minimum total number of shelves, including the initial one, required for this loading process. The packets are named A, B, C, D, E &#133;&#133;.. Any numbers of packets with these names could be kept in the shelf, as in this example: [ZZLLAAJKRDFDDUUGGYFYYKK]. All packets are to be loaded on cars. The cars are lined in order, so that the packets could be loaded on them. The cars are also named [A, B, C, D, E,&#133;&#133;&#133;&#133;.].

2 Answers   Infosys, TCS,


Explain the difference between call by value and call by reference in c language?

0 Answers  


How can I increase the allowable number of simultaneously open files?

1 Answers   ABC,


What are multidimensional arrays?

0 Answers  


When should you not use a type cast?

0 Answers  


The code is::::: if(condition) Printf("Hello"); Else Printf("World"); What will be the condition in if in such a way that both Hello and world are printed in a single attempt?????? Single Attempt in the sense... It must first print "Hello" and it Must go to else part and print "World"..... No loops, Recursion are allowed........................

14 Answers   HOV Services, IBM, Potty,


main() {char a[10]={1,2,3,4,5,6};int x; for(x=0;x<4;x++){ b[x]=x+'a';} printf("%s",b);}

3 Answers  


Write a program in c to input a 5 digit number and print it in words.

11 Answers  


Categories