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}