Hi Guyz am struggling with this code... which i think the problem is with the main function but i can figure it out am using the DevC++ compiler.
#include<iostream>
using namespace std;
int recursiveSequential( int a[], int size, int value ) {
if( size == 0 )
return -1;
if( value == a[ size - 1 ] )
return size - 1;
return recursiveSequential( a, size - 1, value );
}
int main () {
int const length = 10;
int searchV;
int list[10] = { 2, 3, 4, 5, 20, 40, 80, 45, 99, 0};
cout << "Please enter the value to be searched" <<endl;
cin>> search;
cout << recursiveSequential(list, length, searchV) << endl;
return 0;
int searchV;
cin>> search; // ? do you mean searchV?
Did you close the }-brackets at the end of main?
Why is there a int searchV;
but you give the value through cin to search??
What exactly are you trying to do with this function?