int LinearSearch(struct arr, int key) { int i; for(i=0; i<arr.length; i++) { if (key == arr.A[i]) return i; } return -1; } int main() { struct Array arr={{2,3,4,5,6},10,5}; printf("%d\n", LinearSearch(arr,15)); Display(arr); 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