Skip to content

Commit

Permalink
Update ReversingList.c
Browse files Browse the repository at this point in the history
  • Loading branch information
vinayakRodd authored May 12, 2024
1 parent 3afcbaf commit 17a6380
Showing 1 changed file with 32 additions and 2 deletions.
34 changes: 32 additions & 2 deletions LinkedList/SinglyLinkedList/ReversingList.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ struct Node{

int main(){

struct Node *Head=NULL,*ptr,*p,*q;
struct Node *Head=NULL,*ptr,*p,*q,*prev=NULL,*current,*front;
int a;
while(1){
ptr=(struct Node *)malloc(sizeof(struct Node));
Expand Down Expand Up @@ -41,8 +41,38 @@ int main(){
printf("->");
ptr=ptr->next;
}
printf("NULL");

// Reversing Operation //



current = Head;
front = Head;

while(front != NULL){


front = front -> next ;
current -> next = prev;
prev = current;
current = front;

}

ptr = prev;

printf("\n");

while(ptr != NULL){

printf("%d -> ",ptr->data);
ptr = ptr -> next;

}
printf("NULL");




}
}

0 comments on commit 17a6380

Please sign in to comment.