Where is my error?

sir, please help me to find out my error --> https://ide.codingblocks.com/s/450035

hello @chandreshmaurya

check now->

sir, if β€˜9’ is not at left most. then how will we deal with that ?

. . .
…

when left most is not 9 , then we use the same logic that we are using on other digits.
otherwise if it is 9 then we dont change it

sir, but is there any code to find the " 9 is at left most" ? please mention that .

		if (r>4 && n!=9) {//added n!=9 ,so that we dont change left most digit if it is 9 
			number+= ((9-r)*l);
		}

that second statement inside the if is for the same purpose.
pls dry run on this case ->
988
for clarity

sir, it’s okay with the dry run. but, i’m not getting code. how do it differentiate between left most 9 and others 9 ?

n will always be greater than 10 . only in last iteration it will be 9 or less than that.

for example->
n=978
in first iteration n=978 , r=8 , in the end we divide n by 10 so now n will be 97
in second itertion n=97, r=7, in the end we divide n by 10 so now n will be 9
in third itertion(last iteration becuase we have only 3 digit no , it means we are modifying left most digit) n=9, r=9, in the end we divide n by 10 so now n will be 0.
note how n changes , it was less than 10 only in last iteration

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.