program to Reverse a linked list
Answers were Sorted based on User's Feedback
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 |
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 |
Give a very good method to count the number of ones in a 32 bit number. (caution: looping through testing each bit is not a solution)
main() { float f=5,g=10; enum{i=10,j=20,k=50}; printf("%d\n",++k); printf("%f\n",f<<2); printf("%lf\n",f%g); printf("%lf\n",fmod(f,g)); }
main() { int i=-1,j=-1,k=0,l=2,m; m=i++&&j++&&k++||l++; printf("%d %d %d %d %d",i,j,k,l,m); }
void func1(int (*a)[10]) { printf("Ok it works"); } void func2(int a[][10]) { printf("Will this work?"); } main() { int a[10][10]; func1(a); func2(a); } a. Ok it works b. Will this work? c. Ok it worksWill this work? d. None of the above
Find your day from your DOB?
15 Answers Accenture, Microsoft,
#define DIM( array, type) sizeof(array)/sizeof(type) main() { int arr[10]; printf(“The dimension of the array is %d”, DIM(arr, int)); }
Is there any difference between the two declarations, 1. int foo(int *arr[]) and 2. int foo(int *arr[2])
how can i cast a char type array to an int type array
main() { char string[]="Hello World"; display(string); } void display(char *string) { printf("%s",string); }
#define prod(a,b) a*b main() { int x=3,y=4; printf("%d",prod(x+2,y-1)); }
main() { int k=1; printf("%d==1 is ""%s",k,k==1?"TRUE":"FALSE"); }
void main() { int i=5; printf("%d",i+++++i); }