How to remove that condition when first digit is 9 and 9-9=0; and th efirst digit is 0

Hi @kailash_01
You can use if condition in your while loop for which you check if n lies between 0-9.

if(n>=0 && n<=9){
if(n==9){
num+=k*p;
n/=10;
break;
}
}

Here is your corrected code :

If your doubt is clear then mark it as resolved.

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.