Code showing run error
1 Like
hey @kamya, I have made changes to your code and indicated them as comment. You can check them here https://ide.codingblocks.com/s/109524.
Hey @kamya I found following mmistakes in your code which I’ve corrected , I’m listing them all so that you try to avoid them in future.
- in function even( ), in both the loops involving list traversal for finding odd numbers and even numbers and then inserting them into respective lists, you forgot to upgrade p to p->next and m=m->next.
- You didn’t initialize pointer o and e to NULL , which was resulting in segmentation fault.
- after preparing both the lists of even and odd numbers, you called function buildlist again which was unnecessary and may have also confused you as to why your program is not printing anything after entering n integers.
- In function even( ) , in the second loop you’re using m for traversing the list but you’re checking parity of p->data by mistake.
So, that was all I’ve made changes in your code accordingly, but I would like you to make changes yourself according to the points discussed above:slightly_smiling_face:
Here is the corrected code for your referenceCorrected Code