Related to declartion of variabes and array

In 7th line code can we declare the variables and array outside the parameter bracket and when do we use for loop and while loop because they both behave the same way

Hey @vikash3303 those are passed parameters and you cannot declare them inside function! hence you have to mention them in parameters list,
what you can do to avoid it is either make those variables global or take input in the function itself.
Now we use while when we are uncertain about number of iterations(hence we mention the condition), in for loop we know how many times the loop should run.(although in almost any scenario both while and for can be used!)

can we build binary serach algo through for loop and why don’t we define array size in binary_search fuction in line code 7

Yes we can here’s how:
for(l=0,h=n-1;l<=h;){
// same code as in while loop
}
also n is the array size passed as a parameter!

In 7th line code a[ ] is used,size is not defined inside the bracket…

Alright, there’s no need to pass size for 1D arrays.