java - number reversal program gives only the first digit in output instead of the whole number -
string s1; int a, b, c = 0; s1 = t1.gettext(); = integer.parseint(s1); while (a > 0) { b = % 10; c = c * 0 + b; = / 10; } t2.settext("" + c);
here t1,t2 text fields. please let me know did go wrong because getting first digit of number enter in output , not whole number.
your incrementation of c
c = c * 0 + b;
want multiply 10
instead of 0
: c = c * 10 + b;
Comments
Post a Comment