why segmentation error in my program

Change your search function declaration to:

int search(int no,int *num)

Change the way you access to the array elements:

if (no == num[i]) // Instead of *num[i]

and call it like:


I think you have some confusion about arrays, pointers and argument passing.
Also, as comments below your question already point out, you should adopt a better coding style. Your code is really hard to read.

This may be a good start point:

Browse More Popular Posts

Leave a Comment