What is wrong in the code

where i am making the error in the code
#include
using namespace std;
int main() {
int n,k,rem,count=0;
cin>>n>>k;
while(n!=0)
{
rem=n%10;
if(rem==k)
{
count++;
}
cout<<count;
}
return 0;
}

@shdanish1508 There are a few mistakes:

The loop must be like this
while(n!=0)
{
rem=n%10;
if(rem==k)
{
count++;
}
n=n/10;
}

Then place the cout statement outside the loop.

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.