How to count in recusrsion

#include<bits/stdc++.h>
using namespace std; // tower of hanoi

int towerofhanoi(int n,string src,string dest,string helper){
if(n==0){
return 0;
}
int k=1+towerofhanoi(n-1,src,helper,dest);
cout<<"Move "<<n<<"th disk from “<<src<<” to "<<dest<<endl;
k+=towerofhanoi(n-1,dest,helper,src);
}

int main(){
int n;
cin>>n;
cout<<towerofhanoi(n,“T1”,“T3”,“T2”);
return 0;
}

you can use global variable
or pass an parameter in the function argument

if you have further doubt in this feel free to ask

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.