sequantial search algorthim problem

hi , hello every one
I have encountered this problem and this is what made ​​me to come here
It just makes me confused I do not know why I get this error everything is okay

this error i have
: error C2664: 'seqsearch' : cannot convert parameter 1 from 'int' to 'int []'

in line 17

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include <iostream>
using namespace std;

int seqsearch(int list[] , int listlength , int searchitem)
{
	for(int index=0 ; index<listlength ; index++)
		if(list[index]==searchitem)
			return index;
		else
			return -1;
}
int main()
{

    int size, key, arr;
	int list[5]={5,3,4,12,9};
	int pos=seqsearch(arr,size,key);
		if(pos!=-1)
			cout << key << "is found at position" << pos << endl;
		else
			cout << key << "is not found in the list" << endl;
	return 0;
}
Last edited on
Parameter 1 should be 'list', not 'arr'.
'Arr' is not an array, it's only a regular int variable.
Topic archived. No new replies allowed.