Linear Searching Algorithm
Linear Searching Algorithm
INTRODUCTION:
ALGORITHM:
o
o
o
o
o
PROGRAM:
#include<iostream.h>
#include<conio.h>
#include<stdio.h>
int main()
{
int array[100], n, x;
cout<<*********************************
<<This program is to implement linear search algorithm\n
<<*************************************
cout<<Enter how many numbers you are going to enter::;
cin>>n;
cout<<Now enter your elements ::\n;
for(int i=;i<=n;i++)
cin>>array[i];
cout<<Enter the number to be searched ::;
cin>>x;
for(int i=;i<=n;i++)
{
if(array[i]==x)
{
cout<<found at location::<<i <<endl;
break;
}
}
getch();
}
SAMPLE OUTPUT
**************************************...
This program is to implement linear search algorithm
**************************************
Enter how many numbers you are going to enter::5
Now enter your elements ::
1.1
1.2
1.3
1.4
1.5
Enter the number to be searched ::1.5
found at position ::5