Today I was trying to do recursion with multiple functions and I was using some function and in that I was using a function which is declared below it
Here is my code :
#include<bits/stdc++.h>
using namespace std;
#define MOD 10
int f(int x){
if(x == 4) return 1;
return 3*f(((2*x+2)%11)-1);
}
int q(int x){
if(x == 7) return 1;
return f(x) + q((3*x)%MOD);
}
int g(int x){
if(x == 0) return 1;
return (g(x-1)+f(g(x-1)) + f(x-1) + h(x-1))%MOD;
}
int h(int x){
if(x == 0) return 1;
return (2*h(x-1) + g(x-1) + q(f(x-1)%10))%MOD;
}
int main() {
cout << g(4);
return 0;
}
The error is that in the function g(x)
, it is accessing h(x)
which is declared below and h(x)
function is using g(x)
function so not able to do anything
Please let me know what should I do to make this work.
Thanks a lot.