#include <stdio.h>
#include <omp.h>
#define ARRAY_SIZE 1000
#define SEARCH_VALUE 42
int linearSearch(int *arr, int size, int target) {
int result = -1;
#pragma omp parallel for
for (int i = 0; i <size; ++i) {
if (arr[i] == target) {
#pragma omp critical
{
result = i; 
}
}
}
return result;
}
int main() {
int array[ARRAY_SIZE];

for (int i = 0; i < ARRAY_SIZE; ++i) {
array[i] = i;
}
int position = linearSearch(array, ARRAY_SIZE, SEARCH_VALUE);
if (position != -1) {
printf("Value %d found at position %d.\n", SEARCH_VALUE, position);
} else {
printf("Value %d not found in the array.\n", SEARCH_VALUE);
}
return 0;
}
