Posted by : Unknown



#include<iostream.h>
#include<conio.h>

void main()
{
 clrscr();
 int a[20],n,x,i,flag=0;
 cout<<"How many Elements?";
 cin>>n;
 cout<<"\nEnter Elements of the Array\n";

 for(i=0;i<n;++i)
  cin>>a[i];
 cout<<"\nEnter Element to search:";
 cin>>x;

 for(i=0;i<n;++i)
 {
  if(a[i]==x)
  {
   flag=1;
   break;
  }
 }

 if(flag)
  cout<<"\nElement is Found at position "<<i+1;
 else
  cout<<"\nElement not found";
 getch();
}

© Information Technology