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

write asingle linked list which read from two list & the do the following 1 sort the prime & nonprime num (prime should be less tn nonprime) 2 each node has a prime num followd by nonprime 3 add a new node into its sutable plce 4 erase the most three duplicated non prime num 5 find the least duplicated prime num

2390


Write a program using display() function which takes two arguments.

804


Are c and c++ different?

711


What is the identity function in c++? How is it useful?

769


program explaining feautures of c++

2146






Why #include is used?

785


When are exception objects created?

775


Where the memory to the static variables is allocated?

753


Write about c++ storage classes?

945


Difference between a copy constructor and an assignment operator.

748


What is c++ course?

769


What do c++ programmers do?

759


What are the various oops concepts in c++?

780


Does c++ support exception handling?

775


What is late binding c++?

712