Answer:
// C++ code to linearly search x in arr[]. If x Â
// is present then return its location, otherwise Â
// return -1 Â
#include <iostream> Â
using namespace std; Â
int search(int arr[], int n, int x) Â
{ Â
int i; Â
for (i = 0; i < n; i++) Â
 if (arr[i] == x) Â
 return i; Â
return -1; Â
} Â
int main(void) Â
{ Â
int arr[] = { 2, 3, 4, 10, 40 }; Â
int x = 10; Â
int n = sizeof(arr) / sizeof(arr[0]); Â
int result = search(arr, n, x); Â
(result == -1)? cout<<"Element is not present in array"
  : cout<<"Element is present at index " <<result; Â
return 0; Â
} Â