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:

s=search(no,num)

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:
https://www.kernel.org/doc/Documentation/process/coding-style.rst

Browse More Popular Posts

Leave a Comment