Invalid conversion from 'int' to 'int*'

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
#include<iostream>
using namespace std;
int Prime (int array_[5], int st) {
int array_f[5];
int m=0;
int k=0;

do
{




int e=1;
for (int i=2; i<st; i++){
if (st%i==0)
{
e=0;
break;
}


}


if(e==1){array_f[k]=st;k+=1;m+=st;}


st+=1;


}// do
while(k==4);
m/=5;
return m;
}

int main(){
int b=23;
cout<<Prime(b);
return 0;
}


Please, what is wrong?
Many thanks!
Last edited on
Line 3: The Prime function expects two arguments, the first of which is an array (which you never use... do you?), but you call it on line 40 with only one int.

That's the cause of your error. Your code may have other issues (I haven't run it, but some parts look off).

-Albatross
Hello!
The task is so that I have to compute field in Ave function.

I tried like this:

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
int Ave( int sm){

int k=0;

do
{

int e=1;
for (int i=2;i<sm;i++){
if (sm%i==0){e=0;break;}


}

if (e==1){cout<<k<<" " <<sm<<endl;k=k+1;}
sm=sm+1;
}
while(k<5);

return k;

}

int main(){
int x=100;
cout<<Ave(x);
return 0;
}


then, the values I got (5 of them) I wanted to put into an array,

array_f[5]

Like:

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
int Ave(int array_f[5], int sm){

int k=0;

do
{

int e=1;
for (int i=2;i<sm;i++){
if (sm%i==0){e=0;break;}


}

if (e==1){array_f[k]=sm; cout<<k<<" "<<sm<<" "<<array_f[k]<<endl;k=k+1;}
sm=sm+1;
}
while(k<5);

return k;

}

int main(){
int x=128;
cout<<Ave(x);
return 0;
}



Please, what is wrong?
Many thanks!


Topic archived. No new replies allowed.