#include <stdio.
h>
// Function to perform linear search
int linearSearch(int arr[], int size, int target) {
for (int i = 0; i < size; i++) {
if (arr[i] == target) {
return i; // Return the index where target is found
return -1; // Return -1 if the target is not found
int main() {
int arr[100], size, target, result;
// Input the number of elements in the array
printf("Enter the number of elements in the array: ");
scanf("%d", &size);
// Input the elements of the array
printf("Enter %d elements:\n", size);
for (int i = 0; i < size; i++) {
scanf("%d", &arr[i]);
// Input the element to be searched
printf("Enter the element to search: ");
scanf("%d", &target);
// Perform linear search
result = linearSearch(arr, size, target);
// Output the result
if (result != -1) {
printf("Element %d found at index %d.\n", target, result);
} else {
printf("Element %d not found in the array.\n", target);
return 0;