program to Reverse a linked list

Answers were Sorted based on User's Feedback



program to Reverse a linked list..

Answer / vikram singh saini

Here is the link:
http://niitdeveloper.blogspot.com/2010/12/accept-integers-print-in-reverse-order.html

This code accepts integers or numbers from user and print
them in reverse order using linkedlist.

Is This Answer Correct ?    6 Yes 12 No

program to Reverse a linked list..

Answer / shruthirap

node *reverse(node *first)
{
node *temp = NULL;

if(first->next != NULL)
{
temp = reverse(first->next);
temp->next = first;
return first;
}
else
return first;
}
//The only catch is that the supposed to be first node after
reordering, has to be kept either in some global pointer or
passed back by function. That's it :)

Is This Answer Correct ?    16 Yes 36 No

Post New Answer

More C Code Interview Questions

#include<stdio.h> main() { FILE *ptr; char i; ptr=fopen("zzz.c","r"); while((i=fgetch(ptr))!=EOF) printf("%c",i); }

1 Answers  


#include <stdio.h> int main(void) { int a=4, b=2; a=b<<a+b>>2 ; printf("%d",a); return 0; }

0 Answers   Student,


void main() { if(~0 == (unsigned int)-1) printf(“You can answer this if you know how values are represented in memory”); }

1 Answers  


Write a C function to search a number in the given list of numbers. donot use printf and scanf

5 Answers   Honeywell, TCS,


can you use proc sql to manpulate a data set or would u prefer to use proc report ? if so why ? make up an example and explain in detail

0 Answers   TCS,






what is the output of the below program & why ? #include<stdio.h> void main() { int a=10,b=20,c=30; printf("%d",scanf("%d%d%d",&a,&b,&c)); }

6 Answers   CSC, IIIT,


write a c-program to display the time using FOR loop

3 Answers   HCL,


What is the main difference between STRUCTURE and UNION?

13 Answers   HCL,


#define DIM( array, type) sizeof(array)/sizeof(type) main() { int arr[10]; printf(“The dimension of the array is %d”, DIM(arr, int)); }

1 Answers  


main() { char string[]="Hello World"; display(string); } void display(char *string) { printf("%s",string); }

2 Answers   Wipro,


How do you create a really large matrix (i.e. 3500x3500) in C without having the program crash? I can only reach up to 2500. It must have something to do with lack of memory. Please help!

1 Answers  


main() { int i =0;j=0; if(i && j++) printf("%d..%d",i++,j); printf("%d..%d,i,j); }

1 Answers  


Categories