COUNT DIGITS Problem

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

}
cout<< count ;
return count;

}

Please tell the mistake in my logic as in 2 test cases I am getting run time error and @ testcases are correct…
Please tell me

Hello @G_rahil,

Modification:
return 0;

Explanation:
In a C++ program, the statement return 0; is optional: the compiler automatically adds a return 0; if you don’t explicitly return a value.

The return value is the exit code of your program, the shell (or any other application that ran it) can read and use it.
The 0 exit code is a widely accepted convention for ‘OK the program execution was successful’.

Hope, this would help.
Give a like, if you are satisfied.

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.

Do not include break statement.