Even After Odd not working

void evenodd(node*&head){

node*temp=head;
while(temp->next !=NULL){
	if(temp->next->data %2==1){
		node*todelete=temp->next;
		int da=temp->next->data;
		if(temp->next->next !=NULL){
			
			temp->next=temp->next->next;
		}
		else{
             temp->next = NULL;
		}
		delete todelete;
		insertAthead(head,da);
	}
	temp=temp->next;
}

}

Why it is not working for the last elemet

hi @shubham.gupta29062002 sorry for late reply please send the full code in ide.codingblocks.com

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.