Err in liner searcing programm

hi all
when i compile this get
some errors i don't know fixed & where is my mistake
:(


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
  #include <iostream>
using namespace std;
void input(int [],int);
void liner(int [],int,int);
main ()
{
	const int k=5;
	int list[k],no;
	input(list,k);
	cout<<"Enter # student to search:"<<endl;
	cin>>no;
	if(liner(list,k,no)==-1)
	cout<<"number"<<no<<"not exist in list"<<endl;
	else
	cout<<"number"<<no<<"exist in list"<<endl;
	cin.get();
}
//___________________________________________________
void input(int list[],int x)
{
	int i;
	for(i=0;i<x;i++){
		cin>>list[i];
	}
	cin.get();
}
//___________________________________________________
void liner(list [],int len,int no)
{
	int i;
	for(i=0;i<len;i++){
		if(list[i]==0)
		return i;
		return -1;
	}
}

using DEVC++
Last edited on
when i compile this get some errors
Perfect. Now would you mind posting them here so we could deduce what is happening?

The one glaring mistake is that liner() function is declared to not return anything and you still trying to return value from it.
1. void liner(list [],int len,int no)

function needs to return int instead of being void

2.
1
2
3
4
5
6
7
8
9
10
void liner(int list [],int len,int no) // you forgot a type
{
          for(i=0;i<len;i++)
         {
	         if(list[i]==0)  // why are you comparing element with zero? what's the purpose of a variable no?
		      return i;
		
                      return -1;  // this line has to be placed underneath the bracket below
          }
}




Last edited on
Topic archived. No new replies allowed.