Write a program to reverse a linked list?
Answer Posted / prakash d
struct node *ptr1,*ptr2,*ptr3;
ptr1=start; //pointer points to starting node.
ptr2=ptr1->next;
ptr3=ptr2->next;
ptr1->next=NULL;
ptr2->next=ptr1;
while(ptr3!=NULL)
{
ptr1=ptr2;
ptr2=ptr3;
ptr3=ptr3->next;
ptr2->next=ptr1;
}
start=ptr2;
| Is This Answer Correct ? | 13 Yes | 6 No |
Post New Answer View All Answers
Which bit wise operator is suitable for turning off a particular bit in a number?
Can you please explain the difference between using macro and inline functions?
How do you add an element to a set in c++?
Why do we use the using declaration?
What are virtual constructors/destructors?
What are the 3 levels of programming languages?
What is the use of seekg in c++?
What are the differences between the function prototype and the function defi-nition?
Why c++ is created?
What is the c++ code?
How a new element can be added or pushed in a stack?
Explain polymorphism?
What is pure virtual function? Or what is abstract class?
Can we inherit constructor in c++?
What does return 0 do in c++?