#include <iostream>
usingnamespace std;
int f1(int a);
int f2(int &a);
int f3(int b);
int f4(int &b);
int main() {
int a = 1;
int b = 2;
int c = f1(a);
int d = f1(b);
cout << c << endl;
cout << d << endl;
return 0;
}
int f1(int a) {
if (a == 1) {
a *= 3;
cout << a << endl;
int r = f2(a);
cout << a << endl;
return r;
}
if (a == 2) {
a *= 5;
cout << a << endl;
return f3(a);
}
}
int f2(int &a) {
a += 10;
int r = f4(a);
cout << a << endl;
return r;
}
int f3(int b) {
b = b % 11;
int r = f4(b);
cout << b << endl;
return r;
}
int f4(int &b) {
b /= 2;
cout << b << endl;
return b;
}
The correct output is as follows:
1 2 3 4 5 6 7 8 9
3
6
6
6
10
5
5
6
5
Can someone explain the math of how each value is outputted. Thank You!