SOS!!!-function value-PLEASE URGENT!!!

Please, how can I use result a*d from fu function to do other calculation like (a*d)+2 etc, in main or howelse?
Many thans!

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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
  #include<iostream>
using namespace std;

void fu();
int main(){
    for(int i=0;i<3;i++){
    fu();
    cout<<endl;
}
    system("PAUSE");
    return 0;
}

void fu(){
       int a=rand()%100;
       int b=rand()%1000;
       int c=rand()%100;
       int d=rand()%1000;
       int e=rand();
       int z=a*d;
       int p=b*c;
       int k=z-p;
       int n=b*d;
       cout<<k<<" / "<<n;
       }
       
       
       
    
    #include<iostream>
using namespace std;

void fu();
int main(){
    for(int i=0;i<3;i++){
    fu();
    cout<<endl;
}
    system("PAUSE");
    return 0;
}

void fu(){
       int a=rand()%100;
       int b=rand()%1000;
       int c=rand()%100;
       int d=rand()%1000;
       int e=rand();
       int z=a*d;
       int p=b*c;
       int k=z-p;
       int n=b*d;
       cout<<k<<" / "<<n;
       }
       
       
       
    
    
You need to pass them as parameters to fu() to be filled in.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
void fu(int& z)
{
    int a = rand() % 100;
    int d = rand() % 1000;

    z = a * d;
}

int main()
{
    int z;
    f(z);
    a = z + 2;
}
Topic archived. No new replies allowed.