How it is reversing the doubly linked list?

Quiz Q-09:

Predict the modified doubly linked list of the following code for the given doubly linked list as 1<–> 2 <–> 3 <–> 4 <–> 5 <–>6
CPP

void fun(node **head_ref)
{
node *temp = NULL;
node *current = *head_ref;

while (current !=  NULL)
{
    temp = current->prev;
    current->prev = current->next;
    current->next = temp;
    current = current->prev;
}

if(temp != NULL )
    *head_ref = temp->prev;

}

Hey @tasfikrahman007
See in while loop we are swapping next and prev pointers and in last we are changing our head reference to last node
So that is why list is reversing