WAP TO SEARCH FOR A SPECIFIC ELEMENT ( LINEAR SEARCH )
#include<iostream.h>
#include<conio.h>
Void main()
{
int ar[15],i,element,count=0;
clrscr();
for(i=0;i<5;i++)
{
cout<<”Enter
the”<<i+1<<”element:”;
cin>>ar[i];
}
cout<<”Enter the element you want to
search:”;
cin>>element;
for(i=0;i<5;i++)
{
if(element==ar[i])
{
cout<<”Element found at
position”<<i+1;
count=count+1;
break;
}
}
If(count==0)
cout<<”Element not found”;
getch();
}
Comments
Post a Comment