From cc0e866d1d01d73a50e095f9beabd320696c96e0 Mon Sep 17 00:00:00 2001 From: mohit0003 <31645375+mohit0003@users.noreply.github.com> Date: Sat, 23 Oct 2021 10:46:00 +0530 Subject: [PATCH] Update program3.cpp --- program3.cpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/program3.cpp b/program3.cpp index 79dfd9f..2a8273d 100644 --- a/program3.cpp +++ b/program3.cpp @@ -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; } } @@ -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(); }