#include<iostream>
#include<string>
usingnamespace 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
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.