C++ Program to search a Element in Entered array

      No Comments on C++ Program to search a Element in Entered array
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int x,y[100],z,i,s=0;
cout<<"Enter Size of array:- ";
cin>>x;
cout<<"Enter Elements in array:-"<<endl;
for(i=0;i<x;i++)
 {
  cin>>y[i];
 }
cout<<"Enter Element you want to search:- ";
cin>>z;
for(i=0;i<x;i++)
 {
  if(z==y[i])
   {   s=1;
   cout<<"Element is found at location:- "<<i+1;
   }
 }
 if(s==0)
   {
    cout<<"Enetered Element is not found";
   }
   getch();
}

OUTPUT:-

search

Leave a Reply

Your email address will not be published. Required fields are marked *