What is wrong in my code plz check

plz check the code all test cases are not passing

#include using namespace std; class node{ public: int data; node* next; node(int d){ data = d; next = NULL; } }; //Functions for the linked list void insertAtFront(node*&head,int d){ node * n = new node(d); n->next = head; head = n; } node* takeInpu_Better(int n) { int data; node *head = NULL; node *tail = NULL; int cnt=0; while(cnt!=n) { cin >> data; node newNode = new node(data); if(head == NULL) { head = newNode; tail = newNode; } else { tail -> next = newNode; tail = tail -> next; // OR // tail = newNode; } cnt++; } return head; } void print(node head){ while(head!=NULL){ cout<data<<"–>"; head = head->next; } cout<<endl; } int main(){ int n; cin>>n; node head=takeInpu_Better(n); int k; cin>>k; //print(head); int loop_run=n-k; node temp=head; nodeprev =NULL; while(loop_run>0){ prev=temp; temp=temp->next; loop_run–; } node h =head; while(h->next!=NULL){ h=h->next; } if(prev!=NULL){ h->next=head; prev->next=NULL; head=temp; } while(head!=NULL){ cout<data<<" "; head=head->next; } return 0; }

CHeck when k is equal to 0 and k is greater then n
for k greater then n you can do k = k%n
for k =0 & n, you have to print your original linked list without any changes

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.