In this tutorial we are going to print the reverse number of a given number. For better understanding see the below example.


import java.util.Scanner;
public class Reverse {
 
        public static void main(String[] args) {
                System.out.println("Please Enter Number: ");
                Scanner read = new Scanner(System.in);
                int number = read.nextInt();
                int reversedNumber = 0;
                int temp = 0;
                while(number > 0){
			temp = number%10;
                        reversedNumber = reversedNumber * 10 + temp;
                        number = number/10;     
                }
                System.out.println("Reversed Number of "+number+" is: " + reversedNumber);
        }
}
 

Leave a Reply

Your email address will not be published. Required fields are marked *