#include<stdio.h> int main() { int arr[8],i,flag=0,n; printf("Enter 8 Elements of array:\n"); for(i=0;i<8;i++){ printf("arr[%d] = ",i); scanf("%d",&arr[i]); } printf("Enter the element to search in array:"); scanf("%d",&n); for(i=0;i<8;i++){ if(arr[i] == n){ flag = 1; break; } else{ flag = 0; } } if(flag==1){ printf("The element is found at location : %d",i); } else{ printf("Element not found"); } return 0; }
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter