Searching an Array in C Programming

Image result for c programming

Searching an Array in C programming:

Code:
  #include<stdio.h>
int main(void){
  int a[20], find, size,i;
  scanf("%d",&size);
  for(i=1;i<=size;i++)
  {
    scanf("%d",&a[i]);
  }
  scanf("%d",&find);
  for(i=0;i<size;i++)
  {
    if(a[i]==find){
    printf("%d is present in the array",find);
      break;
    }
  }
    if(i==size)
    {
      printf("%d is not present in the array",find);
    }
  return 0;
}

No comments