can i know the source code for reversing a linked list with
out using a temporary variable?

Answer Posted / dinakaran gct

#include<stdio.h>
struct node *head;
void main();
{
//consider head is the first node
reverse(head);
//here print the reversed link list ...thank you;
}
reverse(struct node *cur)
{
if(cur->next==NULL)
reveres(cur->next)
else{temp=head=cur;}
temp->next=cur;
temp=temp->next;
temp->next=NULL;
}

Is This Answer Correct ?    2 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are the similarities between c and c++?

591


what will be the output for the following main() { printf("hi" "hello"); }

9297


What is the purpose of void pointer?

590


Simplify the program segment if X = B then C ← true else C ← false

2575


Can the “if” function be used in comparing strings?

580






What is a static function in c?

612


#define f(g,h) g##h main O int i=0 int var=100 ; print f ("%d"f(var,10));} wat would be the output??

1535


a=10;b= 5;c=3;d=3; if(a printf(%d %d %d %d a,b,c,d) else printf("%d %d %d %d a,b,c,d);

638


Explain what are multibyte characters?

617


What is the difference between exit() and _exit() function?

594


Describe the header file and its usage in c programming?

611


What is const keyword in c?

734


Explain what is wrong in this statement?

626


Is return a keyword in c?

590


Program to find the sum of digits of a given number until the sum becomes a single digit. (e.g. 12345=>1+2+3+4+5=15=>1+5=6)

681