1public class ReverseNumber {
2 public static void main(String[] args) {
3 int num = 1234, reversed = 0;
4
5 while(num != 0) {
6 int digit = num % 10;
7 reversed = reversed * 10 + digit;
8 num = num / 10;
9 }
10 System.out.println("Reversed Number: " + reversed);
11}}
1public class ReverseNumberExample1
2{
3public static void main(String[] args)
4{
5int number = 987654, reverse = 0;
6while(number != 0)
7{
8int remainder = number % 10;
9reverse = reverse * 10 + remainder;
10number = number/10;
11}
12System.out.println("The reverse of the given number is: " + reverse);
13}
14}
1while(num != 0)
2{
3 int digit = num % 10;
4 reversed = reversed * 10 + digit;
5 num /= 10;
6}
1//continue to loop until a value is equal to 0
2
3public class ReverseNum{
4
5 public static void main(String[] args {
6
7 int a = 543;
8 int reverse = 0;
9
10 while(a!=0){ //itera the process
11
12 int digit = a%10; //isolate the last digit number
13
14 reverse = digit + (reverse*10); //append last digit to reverse
15 a=a/10; // remove the last digit from number
16 }
17 System.out.println(reverse);
18
19 } }