Segmentation fault in even after odd

Hello @coolio.boy385,

The logic you have applied inside second while loop is wrong.
You have not handled the links correctly.

Segmentation error occurs when your code tries to access the memory that is read-only.

Moreover, just implement a simple logic,
Check the input:
if it is even, adds at the tail
Else, add at the head(or where the last odd element is present).

This will automatically keep all the odd numbers before even numbers in the list.

Try to resolve the problem.
Hope, this would help.
If you still have doubts, then feel free to ask.

Hello @coolio.boy385,

There are many reasons for segmentation error:
You can read about it from this link.

In your code, the reason is: you are not handling the pointers properly.

I have modified your code:

Hope, this would help…
Give a like if you are satisfied.