i created a variable which will take all the even no. to last like this
void evenafterodd(node*&head){
if(head==NULL){
return;
}
nodeeven=head;
nodetemp=head;
while(temp->next!=NULL){
temp=temp->next;
}
while(even->next!=NULL){
if(even->data%2==0){
temp->next=even;
even->next=NULL;
}
even=even->next;
}
}
but the link will be broken in between for e.g. if lets say the test case is 1 2 2 2 1 so if i am shifting 2 at 1 position in the last the link to next node is broken and it is showing output as 1 1 . So how to create a pointer which will hold the link ?