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


Please Help Members By Posting Answers For Below Questions

Explain the extern storage classes in c++.

542


What are vectors used for in c++?

615


What is ctime c++?

566


What is a type library?

680


What is setfill c++?

675






In c++, what is the difference between method overloading and method overriding?

585


What are arithmetic operators?

529


Write a c program for binary addition of two 8 bit numbers.

3656


what are the decision making statements in C++? Explain if statement with an example?

648


Is c++ proprietary?

572


Write a program which uses functions like strcmp(), strcpy()? etc

609


How are pointers type-cast?

637


What is rtti in c++?

619


What gives the current position of the put pointer?

551


Write a note about the virtual member function?

597