package javabox;
public class ReverseNumberExample {
public static void main(String[] args) {
int n = 1234, s = 0;
while(n>0){
r=n%10; //getting remainder
s=(s*10)+r;
n=n/10;
}
System.out.println("Reversed Number: " + s);
}
}
public class ReverseNumberExample {
public static void main(String[] args) {
int n = 1234, s = 0;
while(n>0){
r=n%10; //getting remainder
s=(s*10)+r;
n=n/10;
}
System.out.println("Reversed Number: " + s);
}
}
Output -
Reversed Number: 4321
No comments:
Post a Comment