Solution explanation ll-k reverse

https://ide.codingblocks.com/s/103309 I tried reversing every three elements and then returning the next element from which the reverse process is to be repeated again. I am not able to find the mistake in my code. Please check.

@samriddhi.srivastava2017 hey samriddhi shrivastav you rev function is need some modification it should be like
node * rev(node * & head , int k){
int x=k;
node * c=head;
node * p=NULL;
node * n=NULL;
int count=0;
while(c!=NULL&&count<x){
//prev=temp;
n=c->next;
c->next=p;
p=c;
c=n;
x- -;
}
if(n!=NULL)
head->next=rev(n,k);
return p;
}
There is no need of ans function just make the changes in your code call this function from main this will work.

thank you sir. it was helpful