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

‘SAVEPOINT’ and ‘ROLLBACK’ is used in oracle database to secure the data comment. Give suitable examples of each with sql command.

0 Answers  


Given an array of length N containing integers between 1 and N, determine if it contains any duplicates.

3 Answers   SilverKey,


What is difference between far and near pointers?

0 Answers  


What is the Difference between Class and Struct?

10 Answers   Motorola,


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,






Look at the Code: #include<string.h> void main() { char s1[]="abcd"; char s2[10]; char s3[]="efgh"; int i; clrscr(); i=strcmp(strcat(s3,ctrcpy(s2,s1))strcat(s3,"abcd")); printf("%d",i); } What will be the output? A)No output B) A Non Integer C)0 D) Garbage

7 Answers   Accenture,


What is the right type to use for boolean values in c?

0 Answers  


How can I prevent another program from modifying part of a file that I am modifying?

0 Answers  


What are local variables c?

0 Answers  


In c programming, explain how do you insert quote characters (? And ?) Into the output screen?

0 Answers  


Can u return two values using return keyword? If yes, how? If no, why?

7 Answers  


What are the __date__ and __time__ preprocessor commands?

0 Answers  


Categories