Count digits problem

#include
using namespace std;
int main() {
int n , d;
int count=0;
while(n>0){
if(n%10==d){
count++;
n=n/10;
}
cout<<count<<endl;

}
return 0;

}
showing time limited exceeded

hello @kartik.tripathi25

this line should be out of the if statement.

this should be out of the while statement

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.