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 using shift_half( ) function to shift the elements of first half array to second half and vice versa.
How many namespaces are there in c++?
Is c++ a float?
Difference between struct and class in terms of access modifier.
find the two largest values among the 6 numbers using control structures : do-while,for,if else,nestedif- else ,while. one or two of them.
What is a multiset c++?
In a function declaration, what does extern mean?
Explain explicit container.
How to declare a function pointer?
Why are arrays usually processed with for loop?
How did c++ start?
Is ca high or low level language?
Can a list of string be stored within a two dimensional array?
Why do we need constructors in c++?
Why is polymorphism useful?