how to find the elements in array c coding

Finding Elements in an Array in C

#include <stdio.h>

int main() {
   int arr[] = {2, 4, 6, 8, 10};
   int search_element = 6;
   int i, flag = 0;

   for (i = 0; i < 5; i++) {
      if (arr[i] == search_element) {
         flag = 1;
         break;
      }
   }

   if (flag == 1)
      printf("Element found at index %d", i);
   else
      printf("Element not found");

   return 0;
}

In this C code: 1. Include the standard input-output library. 2. Define the main function. 3. Create an array and initialize it with values. 4. Define the element to search for. 5. Declare variables for iteration and a flag. 6. Use a for loop to iterate through the array to find the element. 7. If the element is found, set the flag and break out of the loop. 8. Check the flag and print the appropriate message based on whether the element was found.