Kth reverse in linked list

void kthreverse(node*head , int k ){

if (head == NULL || head->next == NULL)
{
    return  ;
}
node*prev = head;
node*temp = head;
node*n = head;

while(n != NULL){
    int b = k;
    while(b--){
        temp = temp->next;
    }
    prev->next = temp->next;
    temp->next = prev;
    n = prev->next;
}  

print_ll(head);

}

what this code doesnt work?

hi @aggarwal.naman21, please refer this article https://www.geeksforgeeks.org/reverse-a-list-in-groups-of-given-size/