Can i do linear search like this as well? with n being the number that i have to find

int LinearSearch(int *a, int n){

 if(n == 0 or n == 1){
	
     return n;
}
          
else{
	if(a == n){
		return a;
	}else{
		LinearSearch(a+1,n);
	}
}

}

hello @JaveedYara
u are not giving the size of array .
how will u stop the execution without knowing the size.

the base case is not correct.

also a is a pointer u cannot compare it with integer.
use astrisk to compare its value.

let me know if u want the solution

Yes Please. if it is possible. please give me the linear Search Solution

@JaveedYara

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.