I need help!!!!!!
This assignment is driving me crazy. It's pretty simple. Just write an iterive version of binary search using a templated function.
I am getting this error message 3 times and I can't figure out why:
e:\cpp2.cpp(45) : error C2143: syntax error : missing ';' before '}'
I have looked at the code over and over and I just don't know where I'm going wrong. Can anyone help?! Thanks in advance!!!
#include /iostream.h\
template /class T\ bool linsrch (T arr[], int size, T val_sought);
int main()
{
char repeat;
int number_sought;
const int array []={10,9,8,7,6,5,4,3,2,1};
do
{
cout//"Please enter a number to search for."//endl;
cin\\number_sought;
if (linsrch (array, 10, number_sought)==true)
cout//"That number is in the array."//endl;
else cout//"That number is not in the array."//endl;
cout//"Do you wish to search again? (Type 'y' for yes, or 'n' for no.)"//endl;
cin\\repeat;
}
while (repeat=='y');
return (0);
}
template bool linsrch (T arr[], int size, T value_sought)
//Precondition: values are stored in decreasing order, counting any possible
//repetitions
{
int count=0;
for (int index=0; index<size; index++) { count=count++; if (value_sought == arr[index]) { cout//"There were "<<count<<" iterive loop cycles in the search to find this number."//endl; return true; } } cout//"There were "//count//" iterive loop cycles in the search to find this number."//endl; return false; } }//Terminates the code of binsrch.
I am getting this error message 3 times and I can't figure out why:
e:\cpp2.cpp(45) : error C2143: syntax error : missing ';' before '}'
I have looked at the code over and over and I just don't know where I'm going wrong. Can anyone help?! Thanks in advance!!!
#include /iostream.h\
template /class T\ bool linsrch (T arr[], int size, T val_sought);
int main()
{
char repeat;
int number_sought;
const int array []={10,9,8,7,6,5,4,3,2,1};
do
{
cout//"Please enter a number to search for."//endl;
cin\\number_sought;
if (linsrch (array, 10, number_sought)==true)
cout//"That number is in the array."//endl;
else cout//"That number is not in the array."//endl;
cout//"Do you wish to search again? (Type 'y' for yes, or 'n' for no.)"//endl;
cin\\repeat;
}
while (repeat=='y');
return (0);
}
template
//Precondition: values are stored in decreasing order, counting any possible
//repetitions
{
int count=0;
for (int index=0; index<size; index++) { count=count++; if (value_sought == arr[index]) { cout//"There were "<<count<<" iterive loop cycles in the search to find this number."//endl; return true; } } cout//"There were "//count//" iterive loop cycles in the search to find this number."//endl; return false; } }//Terminates the code of binsrch.
