long number = 5572331, result =0;
do
{
result *=10;
int digit = number %10;
result+=digit;
number/=10;
}while(number) <----- what are we checking over here??? ---- (Is it that it's getting reduced to a zero so ultimately it will be false ??_)
Printable View
long number = 5572331, result =0;
do
{
result *=10;
int digit = number %10;
result+=digit;
number/=10;
}while(number) <----- what are we checking over here??? ---- (Is it that it's getting reduced to a zero so ultimately it will be false ??_)
the code will not compile, since int is not a boolean.
It would work in C or C++ but Java is more picky about it, so you have to change your while-loop condition to number != 0.
kind regards,
Jos