Help with an array program

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
37
38
39
40
41
42
43
44
#include<iostream>
#include<string>

using namespace std;

int Func1 (int numtimes, int numbers, int Fav, int i, int p);

int main()
{

int numbers[10];
int i;
int Fav;
int p;

 cout<<"enter 10 numbers"<<endl;

for(i =0; i<10; i++)
{
   
    cin>>numbers[10];
      
}

cout<<"Enter your favorite number"<<endl;
cin>>Fav;

cout<<p<<endl;

system ("pause");
return 0;
}

int Func1 (int numtimes, int numbers, int Fav, int i, int p)
{
    for(i =0; i<10; i++)
{
   
if(numbers[i] == Fav)

              p++;
              return p;    
}
}


The program is enter 10 numbers and then you favorite number, the program outputs how many times your favorite number shows up in the list of 10 numbers.

When I compile it says
H:\Compsci\Untitled1.cpp In function `int Func1(int, int, int, int, int)':

39 H:\Compsci\Untitled1.cpp invalid types `int[int]' for array subscript


what am I doing wrong
The numbers parameter of Func1 is of type int. You can't use the subscript operator on an int. You probably want numbers to be a pointer or a reference to array or something like that.
Topic archived. No new replies allowed.