Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions program3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,13 @@ void linkedlist::reverse_consec()
*/

int t;
node *temp=head;
while(temp&&temp->next!=0)
node *temp = head;
while(temp && temp ->next != 0)
{
t=temp->info;
temp->info=temp->next->info;
temp->next->info=t;
temp=temp->next->next;
t = temp->info;
temp->info = temp->next->info;
temp->next->info = t;
temp = temp->next->next;
}

}
Expand All @@ -125,12 +125,13 @@ int main()
l.add_to_tail(ele);
cout<<"\n\twant to enter more(enter y or Y)";
cin>>ch;

}while(ch=='y'||ch=='Y');
cout<<"\n\tLINKLIST IS:";
l.display();
l.reverse_consec();
cout<<"\n\tAFTER REVERSING CONSECUTIVE ELEMENTS:";
cout<<"\n\tLINKLIST IS:";
cout<<"\n\tLINKLIST IS AS FOLLOWS:";
l.display();
getch();
}