int main()
{
int n1,n2,num=0;
int temp =0;
cin>>n1>>n2;
while(n1>0)
{
num = n1%10;
n1=n1/10;
if(n2&num == n2)
{
temp++;
}
}
cout<<temp<<endl;
return 0;
}
Why this shows code show did you account for negative values?
hi @deepshreyamishra301_1918130c8477386b,
write if(num == n2)
instead of if(n2&num == n2)
(you just need to check if that digit is equal to n2)
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.