My LL is not printing after getting reversed

my LL is not printing after getting reversed

its just printing the first element

hi @utkarsh.gupta0311 send the code here

#include

using namespace std;

class node{
public:
int data;
node *next;

node(int d){
    data = d;
    next = NULL;
}

};
void insertathead(node* &head , int d){
if(head == NULL){
head = new node(d);
return;
}

node *n = new node(d);
n->next = head;
head = n;

}

void print(node*head){
while(head!=NULL){
cout<data<<"->";
head=head->next;
}
cout<<endl;
}

node* take_input(){
int d;
std::cin >> d;

node*head = NULL;

while(d!=-1){
    insertathead(head , d);
    cin>>d;
}
return head;

}

ostream& operator<<(ostream &os , node* head){
print(head);
return os;
}

void reverse(node* &head){
node* current = head;
node* previous = NULL;
node* N = NULL;

if(current != NULL){
    N = current->next;
    current->next = previous;
    previous = current;
    current = N;
}

head = previous;

}

int main()
{
node* head = take_input();
cout<<head;
reverse(head);
cout<<head;
return 0;
}

please check and help
output is coming this way
out

hi @utkarsh.gupta0311 use while not if in reverse function

:sob::sob::sob:why do i make so silly mistakes sir
i have spent over 1 hour over this silly mistake…:sob::sob::sob::sob:

@utkarsh.gupta0311 hehe no worries keep coding:)

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.

sir can i ask one thing?

like we have questions on coding blocks do we need to solve questions on platforms like gfg leetcode ?? to maintain ranks? or sde sheets? but coding blocks questions consumes most of the time they are tough too

@utkarsh.gupta0311 no u dont need just build the base and u can use other platforms also