Average value of array_f elements-PLEASE HELP!!!

Hello!
I have b in main, have to find in the Prime function 5 prime numbers bigger than b, fill array_f[5] with them, and count m, as average value of all the array_f elements.

FFunction Prime returns m.

Please, can someone help?
Many thanks!

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
  

int Prime (int array_f[5], int st) {

do
{

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


                         }

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

}
while(a<6);
}
m=(array_f[0]+array_f[1]+array_f[2]+array_f[3]+array_f[4])/5;
return m;
int main(){
int b=23;
cout<<Prime(b);
return 0;
}
Last edited on
I started with this sheme for finding out if the number is prime or not:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23

int Prime (int st) {


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


}

return e;
}

int main(){
int b=23;
cout<<Prime(b);
return 0;
}
Now, function has to find 5 prime numbers >=b

array_f has to save these values as elements.

In main I just call Prime(b) and it writes out m(average value of elements)

Please, all confused, first example like this!!!

Many thanks!
Thinking if I put st+=1 on the right place...
Topic archived. No new replies allowed.