Below is a simple C program that searches for an element in an array and prints the index if the element is found or a message indicating that the element is not present .
Program :
#include <stdio.h>
 #include <conio.h>
Â
Â
int main()
{
  int i,n,key;
 Â
  printf(“Enter size of the array : “);
  scanf(“%d”, &n);
  int arr[n];
  printf(“Enter elements in array : “);
  for(i=0; i<n; i++)
  {
    scanf(“%d”,&arr[i]);
  }
  printf(“Enter the key : “);
  scanf(“%d”, &key);
  Â
  for(i=0; i<n; i++)
  {
    if(arr[i]==key)
    {
printf(“element found “);
      return 0; Â
    }
  }
Â
printf(“element not found”);
}