#include <iostream>
using namespace std;
int count(int V[],int n,int p){
int res;
if(n==0)
return 0;
res=count(V,n-1,p);
if(V[n-1]==p)
res++;
return res;
}
The problem is to find how many times p appear in an array using recursion.
My question is: We called the function directly after we made the initial condition res=count(v,n-1,p)
,when we call it doesn't it go back to if(n==0)
, the way the code is written it just calls it then continues. Sorry i dont know how to explain my question hope someone understands thank you.