Check Wheather a given
digit its present in a number
or not.
Answers
Answered by
1
In order to find this you can use a loop to extract digit by digit and then check it.
for example if we have to search for the digit 8 in a number.
The following loop will do it
int num,n, digit,i;
while(num>=0)
{
n=num%10;
if(n==digit)
{
cout<<"It is present";
i++;
}
num/=10;
}
if(i==0)
cout<<"The digit is absent";
}
Similar questions