Linear Search
#include <iostream>
using namespace std;
int main()
{
int a[50], i, j, n, elem, flag = 0;
cin >> n;
for (int i = 1; i <= n; i++)
{
cin >> a[i];
}
for (int i = 1; i <= n; i++)
{
cout << a[i]<<" ";
}
cout << "Enter the element to be found: "<<endl;
cin >> elem;
for (int i = 1; i <=n; i++)
if (elem == a[i])
{
flag=i;
}
if (flag > 0)
{
cout << "Ethe element found at: " << flag<<endl;
}
else
{
cout << "Element is not found!!! "<<endl;
}
}