HTML & JS
#include<iostream>
using namespace std;
int main()
{
  int a[10]={21, 34, 45,1};
  int search=21;  //element to be searched
  int n=4;
  cout<<"\nThe elements of the array:";
  for(int i=0;i<=n-1;i++)
      cout<<a[i]<<" ";
  int found=0;
  for(int i=0;i<=n-1;i++)
  {
    if(a[i]==search)
    {
       found=1;
       break;
    }
  }
  if(found==1)
     cout<<"\nElement found";  
  else
     cout<<"\nElement not found";
} 

Generated URL:

Output:

The elements of the array:21 34 45 1 
Element found
Report Bug