start workin on C versions

This commit is contained in:
Emanuel Rodriguez 2023-06-27 20:09:20 -07:00
parent 2fef9a3d05
commit 0b2c71d97d
2 changed files with 19 additions and 0 deletions

BIN
c/a.out Executable file

Binary file not shown.

19
c/linear_search.c Normal file
View File

@ -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);
}