[HELP] pls check my JAVA program for errors
Go to solution
Solved by colonel_mortis,
Your problem is this loop
while(temp>0){ //while loop to count number of digits and form multiple of 10 to do modulus division temp=temp%10; d=d*10; } //loop ends
The modulo operator, %, returns the remainder when divided, so 5 % 10 = 5. This means that you have an infinite loop.
To fix it, you need to use / rather than %, so it will divide by 10 each time (and it uses integer division since the arguments are integers, so it rounds down).
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now