If you want to search a number basically you prefer to do a linear search if you have some sorted numbers and your task is to find the specific number what will you do?#include <stdio.h>
int linearSearch(int *arr, int length_arr, int n) {
for (int i = 0; i < length_arr; i++) {
if (arr[i] == n) {
return 1;
}
}
return 0;
}
int main() {
int num[5] = {1, 2, 3, 4, 5};
int length = sizeof(num) / sizeof(int);
printf("%d\n", linearSearch(num, length, 0));
return 0;
}
The t…
Social Plugin