Digits count number

please share me the approach for the program

Here’s the approach.

#include<iostream>
using namespace std;
int main() {
	int num,count,f,n; //f=frequency
	count=0;
    cin>>num;//this should come outside loop
    cin>>f;//this should come outside loop
	while(num!=0)
	{
		n=num%10;//this should be = instead of ==
		if(n==f){
			count=count+1;
		}
        num=num/10;//this should come outside condn
	}
    cout<<count<<endl;//this should come outside loop

	return 0;
}

If this resolved your query then please mark it as resolved

please explain me how should I do it

First take the input number then a digit which you have to check how many times is coming in the number. Take unit digit out one by one and see if it matches with the digit or not. If it does then increase the count by one. And in the last print the count. Count will represent the number of times that digit came in your number.