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
Write a program in C++ for Fibonacci series
What is a constant? Explain with an example.
What is the best book for c++ beginners?
How many different levels of pointers are there?
Which one is a preferred language C or C++? Why?
What is a float in c++?
What doescout<<(0==0) print out a) 0 b) 1 c) Compiler error: Lvalue required
What is the need of a destructor? Explain with the help of an example.
What is a wchar_t in c++?
What can I use instead of namespace std?
What is the average salary of a c++ programmer?
What is difference between n and endl in c++?
What is ios flag in c++?
Define virtual constructor.
What is the best c++ book for beginners?