hi plz help me
i am getting the above error
here i am attaching the program

#include<iostream.h>
#include<stdio.h>
#include<conio.h>
#include<math.h>
using namespace std;
int main()
{
int a[10],t,n,pos;
clrscr();
//Sorting the elements in the array. Sorting technique name is “Bubble Sort”
cout<<"Enter Elements into the Array";
for(int i=0;i<10;i++)
cin>>a;
for( i=0;i<10;i++)
{
for(int j=i+1;j<10;j++)
{
if(a>a[j])  //Elements are sorted in ascending order
{
t = a;
a=a[j];
a[j]=t;
}
}
}
//Till here all the elements are sorted. Now the binary search starts.
cout<<"Enter the element you want to search";
cin>>n;
pos=binarysearch(a[10],0,9,n);
if(pos < 0)
cout<<"Element not Found";
else
cout<<"Element found at Position"<<pos;
getch();
}
//Function Starts
int binarysearch(int x[10],int start,int end,int n)
{
while (start<end)
{
int mid = (start+end)/2;
if(n>x[mid])
start = mid+1;
else if(n<x[mid])
end = mid-1;
else
return mid;
}
return -1;
}

Edited 3 Years Ago by happygeek: fixed formatting

I think that's telling you you're using outdated library names. Your #include's should be

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

Also, in the future, please post your code between code tags, like:

[code]

your code goes here

[/code]
That goes a long way towards making it more readable.

Once you get past the initial problem, you'll find you've got some work to make your code compile. Let us know if you have continued difficulties.

This article has been dead for over six months. Start a new discussion instead.