in this , we will do linear search . we will iterate our while loop till our key not found and then break our loop. and use one variable that do count++ and after when found we print the count value …
int index =0;
while(a[index]!=key){
index++;
} cout<<index;