Don't use global variables. Its a bad programming practice considering the job can be very well done using local ones.
As far as your method is considered its a bit unclean but still if you want to strip off the leading zeroes check one more condition which keeps skipping zero as long as it doesn't encounter a non zero valid digit.
Btw, I see no validation considering that the user is allowed to enter even alphabets and punctuations and get away with them...
Super Moderator
Featured Poster
Reputation Points: 3233
Solved Threads: 719
Failure as a human
Offline 8,871 posts
since Jun 2006