Wrong output in count digit question

#include
using namespace std;
int main() {
int r,n,key,i;
cin>>n;
cin>>key;
while(n>0)
{ r=0;
r=n%10;
if(r==key)
{
i++;
}
n=n/10;
}
cout<<i;
return 0;
}

You did not initialize i.

still same output no change

Check the above code and try to submit. It is passing all the test cases in my side.

its working on coding block ide

thanks for correcting me