Question not clear

plz check logic
if 999 then output should be 009 ?

No it should be 900, because the question states the decimal representation shouldn’t start with 0, and that length was with respect to length of original number. Length of the final number you form should be same as length of initial number you form.

if the no is zero then oupturt should be 0 or 9

x cannot be zero , its given in the question.