Search an element in the array:
- Compare the key element with index element.
- If match – returns the index as element found
- If not found – display error message “Element not found”

Code:
#include<stdio.h> int main() { int arr[6]={10,20,30,40,50,60}, key=30, found=0, i; for(i=0 ; i<6 ; i++) { if(key == arr[i]) { printf(“found @ loc : %d \n”, i); found=1; break; } } if(!found) printf(“element not found\n”); return 0; } |
Search an element in the list:
