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 |
main( ) { void *vp; char ch = ‘g’, *cp = “goofy”; int j = 20; vp = &ch; printf(“%c”, *(char *)vp); vp = &j; printf(“%d”,*(int *)vp); vp = cp; printf(“%s”,(char *)vp + 3); }
#include<stdio.h> main() { int a[2][2][2] = { {10,2,3,4}, {5,6,7,8} }; int *p,*q; p=&a[2][2][2]; *q=***a; printf("%d----%d",*p,*q); }
1. const char *a; 2. char* const a; 3. char const *a; -Differentiate the above declarations.
to remove the repeated cahracter from the given caracter array. i.e.., if the input is SSAD output should of SAD
main() { char *p="hai friends",*p1; p1=p; while(*p!='\0') ++*p++; printf("%s %s",p,p1); }
write a function to give demostrate the functionality of 3d in 1d. function prototye: change(int value,int indexX,int indexY,int indexZ, int [] 1dArray); value=what is the date; indexX=x-asix indexY=y-axis indexZ=z-axis and 1dArray=in which and where the value is stored??
main(){ char a[100]; a[0]='a';a[1]]='b';a[2]='c';a[4]='d'; abc(a); } abc(char a[]){ a++; printf("%c",*a); a++; printf("%c",*a); }
Who could write how to find a prime number in dynamic array?
main() { int x=5; clrscr(); for(;x<= 0;x--) { printf("x=%d ", x--); } } a. 5, 3, 1 b. 5, 2, 1, c. 5, 3, 1, -1, 3 d. –3, -1, 1, 3, 5
why is printf("%d %d %d",i++,--i,i--);
program to Reverse a linked list
12 Answers Aricent, Microsoft, Ness Technologies,
¦void main() ¦{ ¦int i=10,j; ¦ j=i+++i+++i; ¦printf("%d",j); ¦getch(); ¦} ¦ output:-30 but in same question if we write as- ¦void main() ¦{ ¦int i=10; ¦ int j=i+++i+++i; ¦printf("%d",j); ¦getch(); ¦} ¦ output:-33 why output is changed from 30 to 33. Can any body answer...