start workin on C versions
This commit is contained in:
parent
2fef9a3d05
commit
0b2c71d97d
|
@ -0,0 +1,19 @@
|
|||
#include <stdio.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
bool linear_search(int *a, int len, int needle) {
|
||||
for (int i = 0; i < len; i++) {
|
||||
if (a[i] == needle) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
int arr[5] = {1, 2, 3, 4, 5};
|
||||
int n = 5;
|
||||
printf("the value %d is in the array: %d", n, linear_search(arr, 5, n));
|
||||
return(0);
|
||||
}
|
Loading…
Reference in New Issue