Reverse the integer - Java & Python

Pthon:

a =2356
num = 0
while(a!=0):
num = (num*10)+(a%10)
a=a//10
print(num)


Java:

 public class test1123 {


public static void main(String[] args) {

int a =3221;
int num=0;

while(a!=0) {
num = (num*10) + (a % 10);
a = a / 10;
}
System.out.println(num);
}

}

Comments

Popular posts from this blog

Rest Assured

Sort (Bubble) - Java

Rotate the String from position - Java