#include<iostream.h>
#include<conio.h>
void main()
{
int
n,a[10],i,item,j;
clrscr();
cout<<"Enter the size of array
:-"<<endl;
cin>>n;
cout<<"\nEnter the elements of the
array :-"<<endl;
for(i=1;i<=n;i++)
cin>>a[i];
cout<<"\nEnter the element you want to search :-"<<endl;
cin>>item;
int c=0;
for(i=1;i<=n;i++)
{
if(a[i]==item)
{
cout<<"\n"<<item
<<"is found at location "<<i<<endl;
c=1;
break;
}
}
if(c==0)
cout<<"\n"<<item<<"not
found in the list "<<endl;
getch();
}
No comments:
Post a Comment