Ask Question

Name:
Title:
Your Question:

Answer Question

Name:
Your Answer:
User Submitted Source Code!


Description:
  linear
Language: C/C++
Code:
// C++ program to implement Binary Search
#include <iostream>
#include<stdlib.h>

using namespace std;

int main()
{
int a[7], i, c, z=0;

cout<<"Array can support up to 7 numbers.";
cout<<"Please, enter the numbers";

for(i=0;i<7;i++)
{
cin>>a[i];
}

cout<<" Enter Element to Search ";
cin>>c;

for(i=0;i<7;i++)
{
if (c==a[i])
{
z=c;
cout<<"The number has been found at:"<<i;
}
}

if (!(z==c))
cout<<"The number wasn't found, sorry!";

return 0;
}
     
          
Comments: